Windows環境にcomposerを利用してCakePHPを準備する機会があったのでメモ。
準備としてcomposerをWindowsにインストール。
http://codezine.jp/article/detail/7827を参考にインストールしてください。
それではCakePHPを利用するプロジェクトを作成していきます。
1 2 3 4 5 6 7 8 9 |
// プロジェクト用のディレクトリを作る。 > mkdir c:\xampp\htdocs\sample // 移動する。 > cd c:\xampp\htdocs\sample // composer.phar,composer.bat をコピー > cp c:\xampp\php\composer.phar . > cp c:\xampp\php\composer.bat . |
composer.json を作成します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
{ "name": "example-app", "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": "vendors/" }, "extra": { "installer-paths": { "./plugins/{$name}/": [ "cakephp/debug_kit" ] } } } |
composerでCakePHPをインストール
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
$ php composer.phar install // もしくはcomposer.pharで右クリック -> Composer Installを実行 // 下記の感じになればOK. Command: composer install Loading composer repositories with package information Initializing PEAR repository http://pear.cakephp.org Installing dependencies (including require-dev) - Installing composer/installers (v1.0.21) Loading from cache - Installing cakephp/cakephp (2.6.4) Loading from cache - Installing symfony/yaml (v2.6.7) Loading from cache - Installing phpunit/php-text-template (1.2.0) Loading from cache - Installing phpunit/phpunit-mock-objects (1.2.3) Loading from cache - Installing phpunit/php-timer (1.0.5) Loading from cache - Installing phpunit/php-token-stream (1.2.2) Loading from cache - Installing phpunit/php-file-iterator (1.4.0) Loading from cache - Installing phpunit/php-code-coverage (1.2.18) Loading from cache - Installing phpunit/phpunit (3.7.37) Loading from cache - Installing cakephp/debug_kit (2.2.5) Loading from cache phpunit/php-code-coverage suggests installing ext-xdebug (>=2.0.5) phpunit/phpunit suggests installing phpunit/php-invoker (~1.1) Writing lock file Generating autoload files |
bakeをする
c:\xampp\htdocs\sample\vendors\bin\cake.bat を修正する必要があるので開きます。
1 2 3 4 |
@ECHO OFF SET BIN_TARGET=%~dp0/../cakephp/cakephp/lib/Cake/Console/cake :--bash "%BIN_TARGET%" %* cmd /C "%BIN_TARGET%" %* |
1 2 3 4 5 6 7 8 9 10 |
> cd c:\xampp\htdocs\sample\ // 事前にappディレクトリを作成しておかないと「Could not create xxx properly」となる場合があります。 > mkdir app // cake.batのパスを通す > set path=%path%;%cd%\vendors\bin // プロジェクトを作成。 > cake bake project app |
あとはhttpd.confを修正すればOK.
参考サイト
http://qiita.com/ikuwow/items/748613ba234415cc7b0b
http://w.builwing.info/2011/12/09/cake2-0%E3%81%A7bake%E3%81%AB%E3%82%88%E3%82%8B%E3%82%A2%E3%83%97%E3%83%AA%E3%82%B1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%AE%E4%BD%9C%E6%88%90/
Comments are closed