Composerã使ã£ã¦CakePHP2.4.1ã¨DebugKitãã¤ã³ã¹ãã¼ã«ããã¾ã§
CakePHPã®ææ°å®å®çã§ããããã¼ã¸ã§ã³2.4.1ãComposerã使ç¨ãã¦ã¤ã³ã¹ãã¼ã«ãããã©ã°ã¤ã³ã®DebugKitãã¤ã³ã¹ãã¼ã«ããã¾ã§ãå ¬å¼ããã¥ã¡ã³ãããã¨ã«è§£èª¬ãã¾ãã
追è¨(2013/10/2)
ãã®ãã£ã¬ã¯ããªæ§æã ã¨CakePHPæ¬ä½å´ã¨ããã¸ã§ã¯ãå´ã¨ã§å®æ°ã«éããåºã¦ãã¾ãBakeã³ãã³ãã使ããªããªããã¨ãå¤æãã¾ããããªã®ã§ããã£ã¬ã¯ããªæ§æãå
¬å¼ããã¥ã¡ã³ãã«è¿ã¥ããå½¢ã§ã¡ãã£ã¨å¤ãã¾ãã
http://book.cakephp.org/2.0/ja/installation/advanced-installation.html
ã¾ããããã¸ã§ã¯ãã®ã«ã¼ããã£ã¬ã¯ããªã«ãªããã©ã«ããä½ãã¾ããä»åã®ä¾ã§ã¯ãã¼ã ãã£ã¬ã¯ããªã«ä»åã®ããã¸ã§ã¯ãã«ã¼ãã«ãªããexample-appãã¨ããååã§ãã£ã¬ã¯ããªãä½æãã¾ãã
mkdir ~/example-app
次ã«example-appã¸ç§»åãã¦ç¨æãããã£ã¬ã¯ããªã«composerãã¤ã³ã¹ãã¼ã«ãã¾ãã
cd ~/example-app curl -sS https://getcomposer.org/installer | php
ããã¾ã§ã®ãã£ã¬ã¯ããªã®æ§æã¯ãããªæãã§ãã
~/example-app/ composer.phar
次ã«ã¤ã³ã¹ãã¼ã«ããã½ãããè¨è¿°ãããcomposer.jsonãã¨ãããã¡ã¤ã«ãæ°è¦ã«ä½æãã¾ãã
vim ~/example-app/composer.json
å
容ã¯ä»¥ä¸ã®ã¨ããã«è¨è¿°ãã¾ãã
{ "name": "example-app", "repositories": [ { "type": "pear", "url": "http://pear.cakephp.org" } ], "require": { "pear-cakephp/cakephp": ">=2.4.1" }, "config": { "vendor-dir": "Vendor/" } }
ããã¾ã§ã®ãã£ã¬ã¯ããªã®æ§æã¯ãããªæãã§ãã
~/example-app/ composer.phar composer.json
次ã«ãããããcomposerã§CakePHPãã¤ã³ã¹ãã¼ã«ãã¾ãã
以ä¸ã®ã³ãã³ããå®è¡ãã¾ãã
php composer.phar install
ããã ãã§ã¤ã³ã¹ãã¼ã«å®äºã
ããã¾ã§ã®ãã£ã¬ã¯ããªã®æ§æã¯ãããªæãã§ãã
example-app/ composer.phar composer.json Vendor/ bin/ autoload.php composer/ pear-pear.cakephp.org/
次ã«CakePHPããã¸ã§ã¯ããä½æãã¾ãã
bakeã³ãã³ãã使ãã°ç°¡åã«ã³ãã³ãã©ã¤ã³ããããã¸ã§ã¯ããä½æã§ãã¾ãã
Vendor/bin/cake bake project ~/example-app
ããã§ãexample-appãã©ã«ã以ä¸ã«ããã¸ã§ã¯ããä½ããã¾ããã
次ã«webroot/index.phpã«ãã¹ã«é¢ããå®æ°ãå®ç¾©ããã¦ããã®ã§ããããç·¨éã㦠CAKE_CORE_INCLUDE_PATHã®å®æ°ã絶対ãã¹ããç¸å¯¾ãã¹ã«å¤æ´ãã¾ããå¤æ´ããçç±ã¯ããããã¤ããæã«å°ãããã§ãã
CAKE_CORE_INCLUDE_PATHãå®ç¾©ãã¦ããç®æãæ¢ãã¦ãã³ã¡ã³ãã¢ã¦ããã¦ãã以ä¸ã®è¨è¿°ã追å ãã¾ãã
define( 'CAKE_CORE_INCLUDE_PATH', ROOT . DS . APP_DIR . '/Vendor/pear-pear.cakephp.org/CakePHP' );
å
¬å¼ã®ããã¥ã¡ã³ãã¨å®ç¾©å
容ã«éããããã®ã¯ããã£ã¬ã¯ããªæ§é ã®éãã®ããã§ããä»åã®ä¾ã§ã¯ãAPP_DIRãexample-appã«ãªãã®ã§å
¬å¼ããã¥ã¡ã³ãéãã«è¡ãã¨ãexample-app/app/Vendorãå®æ°ã¨ãã¦å®ç¾©ããã¦ãã¾ãã¾ãã
å
¬å¼ããã¥ã¡ã³ãã©ããã«è¨å®ã
次ã«ãã©ã°ã¤ã³ã§ããDebugKitãã¤ã³ã¹ãã¼ã«ãã¾ãã
æåã«ä½ã£ãcomposer.jsonã«ä»¥ä¸ã®è¨è¿°ã追å ãã¾ãã
vim ~/example-app/composer.json
{ "require": { "cakephp/debug_kit": "2.2.*" } }
composer.jsonã®å ¨æãè¼ãã¾ãã
{ "name": "example-app", "repositories": [ { "type": "pear", "url": "http://pear.cakephp.org" } ], "require": { "pear-cakephp/cakephp": ">=2.4.1", "cakephp/debug_kit": "2.2.*" }, "config": { "vendor-dir": "Vendor/" } }
ã¤ã³ã¹ãã¼ã«ããã¾ãã
php composer.phar update
ããã§ã¤ã³ã¹ãã¼ã«ããã¾ãã
ããã¾ã§ã®ãã£ã¬ã¯ããªã®æ§æã¯ãããªæãã§ãã
example-app/ composer.phar composer.json ... çæãããããã¸ã§ã¯ãã®ãã©ã«ã ... Plugin/ DebugKit/ Vendor/ bin/ autoload.php composer/ pear-pear.cakephp.org/
æå¾ã«app/Config/bootstrap.phpãç·¨éãã¦ä»¥ä¸ã®è¨è¿°ã追å ãã¾ãã
// composerã®autoloadãèªã¿è¾¼ã¿ require APP . '/Vendor/autoload.php'; // CakePHPã®ãªã¼ããã¼ãã¼ããã£ããåé¤ããcomposerããå ã«è©ä¾¡ãããããã«å é ã«è¿½å ãã // https://github.com/composer/composer/commit/c80cb76b9b5082ecc3e5b53b1050f76bb27b127b ãåç § spl_autoload_unregister(array('App', 'load')); spl_autoload_register(array('App', 'load'), true, true); CakePlugin::loadAll();
Vendor/autoload.phpãä¸åº¦èªã¿è¾¼ãã°è¯ãç¶æ ã«ãªãã®ã§ãComposerçµç±ã§ã¤ã³ã¹ãã¼ã«ããã ãã§ãã
CakePlugin::loadAll()ã§ãã©ã°ã¤ã³ãèªã¿è¾¼ã¿ã¾ãã
ããã§å®äºããã¨ã¯ãdatabaseã®è¨å®ã ãã
å
¬å¼ããã¥ã¡ã³ãã®ããæ¹ã¨ã¯çµæ§éãã¾ããã«è¿ã¥ãã¾ããã