From e714341ce344c128456996203fb78df0c5c9b7cd Mon Sep 17 00:00:00 2001 From: euromark Date: Tue, 5 Aug 2014 03:53:40 +0200 Subject: [PATCH] Auto-detect composer installed CakePHP folder. --- app/webroot/index.php | 12 +++++++++++- app/webroot/test.php | 12 +++++++++++- lib/Cake/Console/Templates/skel/webroot/index.php | 10 ++++++++++ lib/Cake/Console/Templates/skel/webroot/test.php | 12 +++++++++++- 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/app/webroot/index.php b/app/webroot/index.php index e29104388..6d4fa486b 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -26,7 +26,7 @@ if (!defined('DS')) { } /** - * These defines should only be edited if you have cake installed in + * These defines should only be edited if you have CakePHP installed in * a directory layout other than the way it is distributed. * When using custom settings be sure to use the DS and do not add a trailing DS. */ @@ -63,6 +63,16 @@ if (!defined('APP_DIR')) { */ //define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib'); +/** + * This auto-detects CakePHP as a composer installed library. + * You may remove this if you are not planning to use composer (not recommended, though). + */ +$vendorPath = ROOT . DS . APP_DIR . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib'; +$dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php'; +if (!defined('CAKE_CORE_INCLUDE_PATH') && file_exists($vendorPath . DS . $dispatcher)) { + define('CAKE_CORE_INCLUDE_PATH', $vendorPath); +} + /** * Editing below this line should NOT be necessary. * Change at your own risk. diff --git a/app/webroot/test.php b/app/webroot/test.php index 0949f3ce3..58e5c37e9 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -27,7 +27,7 @@ if (!defined('DS')) { } /** - * These defines should only be edited if you have cake installed in + * These defines should only be edited if you have CakePHP installed in * a directory layout other than the way it is distributed. * When using custom settings be sure to use the DS and do not add a trailing DS. */ @@ -61,6 +61,16 @@ if (!defined('APP_DIR')) { */ //define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib'); +/** + * This auto-detects CakePHP as a composer installed library. + * You may remove this if you are not planning to use composer (not recommended, though). + */ +$vendorPath = ROOT . DS . APP_DIR . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib'; +$dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php'; +if (!defined('CAKE_CORE_INCLUDE_PATH') && file_exists($vendorPath . DS . $dispatcher)) { + define('CAKE_CORE_INCLUDE_PATH', $vendorPath); +} + /** * Editing below this line should not be necessary. * Change at your own risk. diff --git a/lib/Cake/Console/Templates/skel/webroot/index.php b/lib/Cake/Console/Templates/skel/webroot/index.php index 61737e61b..4b67fafa4 100644 --- a/lib/Cake/Console/Templates/skel/webroot/index.php +++ b/lib/Cake/Console/Templates/skel/webroot/index.php @@ -54,6 +54,16 @@ if (!defined('APP_DIR')) { */ //define('CAKE_CORE_INCLUDE_PATH', __CAKE_PATH__); +/** + * This auto-detects CakePHP as a composer installed library. + * You may remove this if you are not planning to use composer (not recommended, though). + */ +$vendorPath = ROOT . DS . APP_DIR . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib'; +$dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php'; +if (!defined('CAKE_CORE_INCLUDE_PATH') && file_exists($vendorPath . DS . $dispatcher)) { + define('CAKE_CORE_INCLUDE_PATH', $vendorPath); +} + /** * Editing below this line should NOT be necessary. * Change at your own risk. diff --git a/lib/Cake/Console/Templates/skel/webroot/test.php b/lib/Cake/Console/Templates/skel/webroot/test.php index 95ee89a5f..0de048175 100644 --- a/lib/Cake/Console/Templates/skel/webroot/test.php +++ b/lib/Cake/Console/Templates/skel/webroot/test.php @@ -18,7 +18,7 @@ if (!defined('DS')) { } /** - * These defines should only be edited if you have cake installed in + * These defines should only be edited if you have CakePHP installed in * a directory layout other than the way it is distributed. * When using custom settings be sure to use the DS and do not add a trailing DS. */ @@ -52,6 +52,16 @@ if (!defined('APP_DIR')) { */ //define('CAKE_CORE_INCLUDE_PATH', __CAKE_PATH__); +/** + * This auto-detects CakePHP as a composer installed library. + * You may remove this if you are not planning to use composer (not recommended, though). + */ +$vendorPath = ROOT . DS . APP_DIR . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib'; +$dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php'; +if (!defined('CAKE_CORE_INCLUDE_PATH') && file_exists($vendorPath . DS . $dispatcher)) { + define('CAKE_CORE_INCLUDE_PATH', $vendorPath); +} + /** * Editing below this line should not be necessary. * Change at your own risk.