9 * This source file is subject to the new BSD license that is bundled
10 * with this package in the file LICENSE.
11 * It is also available through the world-wide-web at this URL:
12 * http://phergie.org/license
16 * @author Phergie Development Team <team@phergie.org>
17 * @copyright 2008-2010 Phergie Development Team (http://phergie.org)
18 * @license http://phergie.org/license New BSD License
19 * @link http://pear.phergie.org/package/Phergie
23 * Autoloader for Phergie classes.
27 * @author Phergie Development Team <team@phergie.org>
28 * @license http://phergie.org/license New BSD License
29 * @link http://pear.phergie.org/package/Phergie
31 class Phergie_Autoload
34 * Constructor to add the base Phergie path to the include_path.
38 public function __construct()
40 $path = realpath(dirname(__FILE__) . '/..');
41 $includePath = get_include_path();
42 $includePathList = explode(PATH_SEPARATOR, $includePath);
43 if (!in_array($path, $includePathList)) {
49 * Autoload callback for loading class files.
51 * @param string $class Class to load
55 public function load($class)
57 include str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
61 * Registers an instance of this class as an autoloader.
65 public static function registerAutoloader()
67 spl_autoload_register(array(new self, 'load'));
71 * Add a path to the include path.
73 * @param string $path Path to add
77 public static function addPath($path)
79 set_include_path($path . PATH_SEPARATOR . get_include_path());