Cakephp の理想的なディレクトリ構成についてです。
Vagrant でローカル開発環境を作り、Cakephp2 の勉強を始めようとしています。
何度か Cakephp2 を使ってアプリ開発はしたことがあるのですが、今回 Composer や bake を使ってみたいと思い、Vagrant で開発をしています。
composer を使って cakephp や Debug_Kit をインストールしてみたのですが、いまいちしっくりこないので、cakephp の理想のディレクトリ構造が知りたいのです。
また、git での管理も考えているので管理しやすい構成だと嬉しいです。
composer.jsonはこのように書きました。
{ "name": "tutorial", "repositories": [ { "type": "pear", "url": "http://pear.cakephp.org" } ], "require": { "cakephp/cakephp": ">=2.6.4,<3.0.0" }, "require-dev": { "phpunit/phpunit": "3.7.37", "cakephp/debug_kit" : ">=2.2.4,<3.0.0" }, "config": { "vendor-dir": "Vendor/" } }
このcomposer.jsonでインストールを実行し、bake を使ってtutorialというアプリを生成すると、以下のようになりました。
vagrant/ ├── Plugin │ └── DebugKit ├── Vendor │ ├── autoload.php │ ├── bin │ ├── cakephp │ │ └── cakephp │ │ ├── app │ │ ├── lib │ │ ├── plugins │ │ └── vendors │ └── phpunit ├── html │ ├── css │ ├── index.php │ └── js └── tutorial ├── Config ├── Console ├── Controller ├── Lib ├── Locale ├── Model ├── Plugin ├── Test ├── Vendor ├── View ├── index.php ├── tmp └── webroot
/vagrant/html が DocumentRoot になっているので、webroot の中身を
/vagrant/htmlに移し、定数の設定などを行ったのですが、うまく動きませんでした。
###試したこと
/vagrant/tutorial を /Vendor/cakephp/cakephp の中に作成すると、cakephp のインストール完了画面が正しく表示されました。
ただ、Debug_Kit がうまく読み込めませんでした。
また、cakephp をまるごと DocumentRoot内に配置することも考えたのですが、セキュリティ的に好ましくないと聞いたので、できれば外に出したいなと考えています。
###補足情報(言語/FW/ツール等のバージョンなど)
macOS 10.12.3
vagrant
CentOS 7.0
php 5.6
cakephp 2.9
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。