Permalink
Browse files

Re-adding support for PHP's include_path.

Moving constants that are made of other constants into bootstrap.php
  • Loading branch information...
1 parent e083b21 commit 721c438817254e12096273afc0941297771a314d @markstory markstory committed with markstory Jul 28, 2011
View
@@ -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);
View
@@ -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);
}
View
@@ -44,13 +44,14 @@
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('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);
}
@@ -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'))));
@@ -44,13 +44,14 @@
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('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);
}
@@ -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);
View
@@ -23,18 +23,21 @@
}
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.

0 comments on commit 721c438

Please sign in to comment.