diff --git a/app/Console/cake.php b/app/Console/cake.php index b9c404167..8b30ffd84 100644 --- a/app/Console/cake.php +++ b/app/Console/cake.php @@ -3,8 +3,6 @@ /** * Command-line code generation utility to automate programmer chores. * - * Shell dispatcher class - * * PHP 5 * * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) @@ -15,10 +13,29 @@ * * @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package app.console - * @since CakePHP(tm) v 1.2.0.5012 + * @package app.Console + * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -require_once(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'lib'. DIRECTORY_SEPARATOR . 'Cake' . DIRECTORY_SEPARATOR . 'Console' . DIRECTORY_SEPARATOR . 'ShellDispatcher.php'); +$ds = DIRECTORY_SEPARATOR; +$dispatcher = 'Cake' . $ds . 'Console' . $ds . 'ShellDispatcher.php'; +$found = false; +$paths = explode(PATH_SEPARATOR, ini_get('include_path')); + +foreach ($paths as $path) { + if (file_exists($path . $ds . $dispatcher)) { + $found = $path; + } +} + +if (!$found && function_exists('ini_set')) { + $root = dirname(dirname(dirname(__FILE__))); + ini_set('include_path', $root . $ds. 'lib' . PATH_SEPARATOR . ini_get('include_path')); +} + +if (!include($dispatcher)) { + trigger_error('Could not locate CakePHP core files.', E_USER_ERROR); +} +unset($paths, $path, $found, $dispatcher, $root, $ds); return ShellDispatcher::run($argv); diff --git a/app/webroot/index.php b/app/webroot/index.php index 943e310aa..31901c223 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -44,13 +44,17 @@ if (!defined('APP_DIR')) { define('APP_DIR', basename(dirname(dirname(__FILE__)))); } + /** * The absolute path to the "cake" directory, WITHOUT a trailing DS. * + * Un-comment this line to specify a fixed path to CakePHP. + * This should point at the directory containg `Cake`. + * + * For ease of development CakePHP uses PHP's include_path. If you + * cannot modify your include_path set this value. */ - if (!defined('CAKE_CORE_INCLUDE_PATH')) { - define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib'); - } + //define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib'); /** * Editing below this line should NOT be necessary. @@ -63,11 +67,20 @@ if (!defined('WWW_ROOT')) { define('WWW_ROOT', dirname(__FILE__) . DS); } - if (!defined('CORE_PATH')) { - define('APP_PATH', ROOT . DS . APP_DIR . DS); - define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); + + if (!defined('CAKE_CORE_INCLUDE_PATH')) { + if (function_exists('ini_set')) { + ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path')); + } + if (!include('Cake' . DS . 'bootstrap.php')) { + $failed = true; + } + } else { + if (!include(CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) { + $failed = true; + } } - if (!include(CORE_PATH . 'Cake' . DS . 'bootstrap.php')) { + if (!empty($failed)) { trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR); } diff --git a/app/webroot/test.php b/app/webroot/test.php index aa6759d06..f48bfb593 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -44,13 +44,14 @@ ini_set('display_errors', 1); if (!defined('APP_DIR')) { define('APP_DIR', basename(dirname(dirname(__FILE__)))); } + /** * The absolute path to the "Cake" directory, WITHOUT a trailing DS. * + * For ease of development CakePHP uses PHP's include_path. If you + * need to cannot modify your include_path, you can set this path. */ - if (!defined('CAKE_CORE_INCLUDE_PATH')) { - define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib'); - } + //define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib'); /** * Editing below this line should not be necessary. @@ -63,11 +64,20 @@ if (!defined('WEBROOT_DIR')) { if (!defined('WWW_ROOT')) { define('WWW_ROOT', dirname(__FILE__) . DS); } -if (!defined('CORE_PATH')) { - define('APP_PATH', ROOT . DS . APP_DIR . DS); - define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); + +if (!defined('CAKE_CORE_INCLUDE_PATH')) { + if (function_exists('ini_set')) { + ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path')); + } + if (!include('Cake' . DS . 'bootstrap.php')) { + $failed = true; + } +} else { + if (!include(CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) { + $failed = true; + } } -if (!include(CORE_PATH . 'Cake' . DS . 'bootstrap.php')) { +if (!empty($failed)) { trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR); } diff --git a/lib/Cake/Console/Templates/skel/webroot/index.php b/lib/Cake/Console/Templates/skel/webroot/index.php index 7b67ae20b..2dced12c7 100644 --- a/lib/Cake/Console/Templates/skel/webroot/index.php +++ b/lib/Cake/Console/Templates/skel/webroot/index.php @@ -44,13 +44,17 @@ if (!defined('APP_DIR')) { define('APP_DIR', basename(dirname(dirname(__FILE__)))); } + /** * The absolute path to the "cake" directory, WITHOUT a trailing DS. * + * Un-comment this line to specify a fixed path to CakePHP. + * This should point at the directory containg `Cake`. + * + * For ease of development CakePHP uses PHP's include_path. If you + * need to squeeze a bit more performance you can set this path. */ - if (!defined('CAKE_CORE_INCLUDE_PATH')) { - define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib'); - } + //define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib'); /** * Editing below this line should NOT be necessary. @@ -63,11 +67,20 @@ if (!defined('WWW_ROOT')) { define('WWW_ROOT', dirname(__FILE__) . DS); } - if (!defined('CORE_PATH')) { - define('APP_PATH', ROOT . DS . APP_DIR . DS); - define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); + + if (!defined('CAKE_CORE_INCLUDE_PATH')) { + if (function_exists('ini_set')) { + ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path')); + } + if (!include('Cake' . DS . 'bootstrap.php')) { + $failed = true; + } + } else { + if (!include(CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) { + $failed = true; + } } - if (!include(CORE_PATH . 'Cake' . DS . 'bootstrap.php')) { + if (!empty($failed)) { trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR); } @@ -76,5 +89,6 @@ } App::uses('Dispatcher', 'Routing'); + $Dispatcher = new Dispatcher(); $Dispatcher->dispatch(new CakeRequest(), new CakeResponse(array('charset' => Configure::read('App.encoding')))); diff --git a/lib/Cake/Console/Templates/skel/webroot/test.php b/lib/Cake/Console/Templates/skel/webroot/test.php index aa6759d06..f48bfb593 100644 --- a/lib/Cake/Console/Templates/skel/webroot/test.php +++ b/lib/Cake/Console/Templates/skel/webroot/test.php @@ -44,13 +44,14 @@ ini_set('display_errors', 1); if (!defined('APP_DIR')) { define('APP_DIR', basename(dirname(dirname(__FILE__)))); } + /** * The absolute path to the "Cake" directory, WITHOUT a trailing DS. * + * For ease of development CakePHP uses PHP's include_path. If you + * need to cannot modify your include_path, you can set this path. */ - if (!defined('CAKE_CORE_INCLUDE_PATH')) { - define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib'); - } + //define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib'); /** * Editing below this line should not be necessary. @@ -63,11 +64,20 @@ if (!defined('WEBROOT_DIR')) { if (!defined('WWW_ROOT')) { define('WWW_ROOT', dirname(__FILE__) . DS); } -if (!defined('CORE_PATH')) { - define('APP_PATH', ROOT . DS . APP_DIR . DS); - define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); + +if (!defined('CAKE_CORE_INCLUDE_PATH')) { + if (function_exists('ini_set')) { + ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path')); + } + if (!include('Cake' . DS . 'bootstrap.php')) { + $failed = true; + } +} else { + if (!include(CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) { + $failed = true; + } } -if (!include(CORE_PATH . 'Cake' . DS . 'bootstrap.php')) { +if (!empty($failed)) { trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR); } diff --git a/lib/Cake/Console/cake.php b/lib/Cake/Console/cake.php index 6e4381516..28282e675 100644 --- a/lib/Cake/Console/cake.php +++ b/lib/Cake/Console/cake.php @@ -19,6 +19,6 @@ * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR. 'ShellDispatcher.php'); +require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ShellDispatcher.php'); return ShellDispatcher::run($argv); diff --git a/lib/Cake/bootstrap.php b/lib/Cake/bootstrap.php index 2696b06b1..21b2a1e6d 100644 --- a/lib/Cake/bootstrap.php +++ b/lib/Cake/bootstrap.php @@ -23,18 +23,21 @@ if (!defined('E_DEPRECATED')) { } error_reporting(E_ALL & ~E_DEPRECATED); -/** - * If the index.php file is used instead of an .htaccess file - * or if the user can not set the web root to use the public - * directory we will define ROOT there, otherwise we set it - * here. - */ - if (!defined('ROOT')) { - define('ROOT', '../'); - } - if (!defined('WEBROOT_DIR')) { - define('WEBROOT_DIR', 'webroot'); - } +if (!defined('CAKE_CORE_INCLUDE_PATH')) { + define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(__FILE__))); +} + +if (!defined('CORE_PATH')) { + define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); +} + +if (!defined('APP_PATH')) { + define('APP_PATH', ROOT . DS . APP_DIR . DS); +} + +if (!defined('WEBROOT_DIR')) { + define('WEBROOT_DIR', 'webroot'); +} /** * Path to the cake directory.