Skip to content

Instantly share code, notes, and snippets.

@nojimage nojimage/bake-composer.sh
Last active Dec 25, 2015

Embed
What would you like to do?
ComposerでインストールしたCakePHPからプロジェクトを生成して、CAKE_CORE_INCLUDE_PATHの相対パス化とautoloaderの読込み。
#!/usr/bin/env bash
Vendor/bin/cake bake project --empty -v app
# replace include_path
replace="s/define('CAKE_CORE_INCLUDE_PATH',.*$/define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib');/"
sed -i .orig -e "$replace" app/webroot/index.php app/webroot/test.php
## # replace console path, if CakePHP < 2.5
## replace="s/ini_set('include_path',.*$/ini_set('include_path', \$root . PATH_SEPARATOR . \$root . \$ds . 'Vendor' . \$ds . 'cakephp' . \$ds . 'cakephp' . \$ds . 'lib' . PATH_SEPARATOR . ini_get('include_path'));/"
##
## sed -i .orig -e "$replace" app/Console/cake.php
# load composer autoloader in bootstrap.php
cat <<EOT >> app/Config/bootstrap.php
// Load composer autoload.
require ROOT . '/Vendor/autoload.php';
// Remove and re-prepend CakePHP's autoloader as composer thinks it is the most important.
// See https://github.com/composer/composer/commit/c80cb76b9b5082ecc3e5b53b1050f76bb27b127b
spl_autoload_unregister(array('App', 'load'));
spl_autoload_register(array('App', 'load'), true, true);
EOT
# set permission
chmod -R o+w app/tmp/
{
"name": "your_vendor/your_project",
"require": {
"cakephp/cakephp": "~2.6.1",
"composer/installers": "*",
"cakephp/debug_kit": "2.2.*",
"cakedc/migrations": "*",
"cakedc/search": "*",
"cakedc/utils": "*",
"cakedc/users": "*"
},
"require-dev": {
"phpunit/phpunit": "~3.7"
},
"config": {
"vendor-dir": "Vendor/"
},
"extra": {
"installer-paths": {
"plugins/{$name}/": ["type:cakephp-plugin"]
}
}
}
@nojimage

This comment has been minimized.

Copy link
Owner Author

commented Dec 12, 2013

consoleスクリプトのパスを書き換え忘れてた。

@nojimage

This comment has been minimized.

Copy link
Owner Author

commented Feb 6, 2014

CakePHPの本体がPackagistに登録されたのでパス等々の修正

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.