示例#1
0
 /**
  * 自动加载,只支持命名空间方式
  * @param array $config
  * @return \Core\Application
  */
 public static function init_autoload()
 {
     spl_autoload_extensions('.php');
     spl_autoload_register();
     //spl_autoload_extensions ( '.php' );
     //spl_autoload_register ('autoloader');
 }
示例#2
0
 public static function register($prepend = false)
 {
     $error = false;
     if (self::$autoloader_set) {
         trigger_error("Auto loader already set", E_USER_NOTICE);
     } else {
         self::add_path(__DIR__ . DIRECTORY_SEPARATOR . "..");
         $class_extensions = spl_autoload_extensions();
         if (strpos($class_extensions, ".php") === false) {
             spl_autoload_extensions($class_extensions . ",.php");
         }
         if (is_array(spl_autoload_functions()) && in_array("spl_autoload", spl_autoload_functions())) {
             trigger_error("Auto loader already set", E_USER_NOTICE);
         } else {
             if (PHP_VERSION_ID < 50300) {
                 if (!spl_autoload_register("spl_autoload")) {
                     $error = true;
                 }
             } else {
                 if (!spl_autoload_register("spl_autoload", true, $prepend)) {
                     $error = true;
                 }
             }
         }
         if ($error) {
             trigger_error("Could not add autoloader to the queue", E_USER_NOTICE);
         } else {
             self::$autoloader_set = true;
         }
     }
 }
 public function helper($class)
 {
     $class = preg_replace('/_helper$/ui', '', $class);
     set_include_path(get_include_path() . PATH_SEPARATOR . '/helper/');
     spl_autoload_extensions('.helper.php');
     spl_autoload($class);
 }
示例#4
0
 public function helper($class)
 {
     $class = $this->trim_namespace($class);
     set_include_path($this->registry->appDir . '/helpers/');
     spl_autoload_extensions('.help.php');
     spl_autoload($class);
 }
 private function createSPLAutoloaders()
 {
     spl_autoload_register(null, false);
     spl_autoload_extensions('.php');
     spl_autoload_register(array('Loader', 'loadGeneric'));
     spl_autoload_register(array('Loader', 'loadModule'));
 }
示例#6
0
/**
 * 自动加载
 *
 * @param $className
 */
function zroneClassLoader($className)
{
    $path = array(str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "Vendor/"), str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "FrameWork/"), str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "Application/"));
    if (isset($path) && is_array($path)) {
        $Iterator = new ArrayIterator($path);
        $Iterator->rewind();
        $pathString = "";
        while ($Iterator->valid()) {
            $pathString .= $Iterator->current() . ";";
            if ($Iterator->key() == count($path) - 1) {
                $pathString = rtrim($pathString, ";");
            }
            $Iterator->next();
        }
        set_include_path($pathString);
        spl_autoload_extensions(".php, .class.php");
        spl_autoload($className);
    } else {
        try {
            throw new Exception("<code style='color: red; font-size: 22px; display: block; text-align: center; height: 40px; line-height: 40px;'>I'm sorry, my dear! The FrameWork is Wrong……😫</code>");
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    }
}
示例#7
0
文件: App.php 项目: hhz1084/YObject
 public static function setPath()
 {
     $path = array(get_include_path(), ROOT_PATH . 'class');
     set_include_path(implode(PATH_SEPARATOR, $path));
     spl_autoload_extensions('.php');
     spl_autoload_register();
 }
示例#8
0
 /**
  * Autoloader Class.
  *
  * @return void
  */
 public function init()
 {
     // Specify the extensions that may be loaded
     spl_autoload_extensions('.class.php, .interface.php, .trait.php');
     // Register the loader methods
     spl_autoload_register(array(__CLASS__, '_loadClass'));
     $this->_loadFile();
 }
示例#9
0
 protected function initLoader()
 {
     $previousExtensions = explode(',', spl_autoload_extensions());
     if (!in_array('.php', $previousExtensions)) {
         spl_autoload_extensions(spl_autoload_extensions() . ',.php');
     }
     spl_autoload_register('spl_autoload', true, true);
 }
示例#10
0
文件: App.php 项目: ar-perficient/mvc
 /**
  * Run the application
  */
 public function run()
 {
     spl_autoload_extensions('.php, .class.php, .lib.php');
     spl_autoload_register(array(self::instance(), '_autoload'));
     $this->_loadDir();
     $con = Config_Framework_Database::getDbConn();
     new Config_Framework_Route();
 }
示例#11
0
 public function init()
 {
     define('CLASS_DIR', 'core/');
     set_include_path(get_include_path() . PATH_SEPARATOR . CLASS_DIR);
     spl_autoload_extensions('.class.php');
     spl_autoload_register();
     $this->registry = Registry::getInstance();
 }
 /**
  * Register method to autoload php classes files
  *
  * @static
  * @access	public
  */
 public static function load()
 {
     if (!extension_loaded('spl')) {
         die('SPL extension not loaded!');
     }
     spl_autoload_register(null, false);
     spl_autoload_extensions('.inc.php, .view.php, .library.php');
     spl_autoload_register('self::autoloader', true);
 }
示例#13
0
 /**
  *
  */
 protected function __construct()
 {
     /*** specify extensions that may be loaded ***/
     spl_autoload_extensions('.php, .class.php, .inc.php');
     /*** nullify any existing autoloads ***/
     // spl_autoload_register(null, false);
     spl_autoload_register(__NAMESPACE__ . '\\ClassesLoader::registerClass');
     // constants
     $this->constants = new Constants();
 }
示例#14
0
 /**
  * Init Autoload Class.
  *
  * @return void
  */
 public function init()
 {
     // Specify the extensions that may be loaded
     spl_autoload_extensions('.php');
     /** Register the loader methods **/
     spl_autoload_register(array(__CLASS__, '_loadController'));
     spl_autoload_register(array(__CLASS__, '_loadClass'));
     spl_autoload_register(array(__CLASS__, '_loadModel'));
     spl_autoload_register(array(__CLASS__, '_loadForm'));
 }
示例#15
0
 /**
  * Autoloader Class.
  *
  * @return void
  */
 public function init()
 {
     // Specify the extensions that may be loaded
     spl_autoload_extensions('.class.php, .interface.php, .trait.php');
     // Register the loader methods
     spl_autoload_register(array(__CLASS__, '_loadClass'));
     $this->_loadFile('Core/License.class.php');
     $this->_loadFile('Core/Kernel.class.php');
     // Include Composer libraries (GeoIp2, Swift, ...)
     require_once PH7_PATH_PROTECTED . 'vendor/autoload.php';
 }
示例#16
0
 private function base_class($className)
 {
     $path = array();
     $pathDir = array();
     $path = explode('_', $className);
     $arrCount = count($path) - 1;
     $pathDir = implode("/", array_slice($path, 0, $arrCount));
     set_include_path(ROOT_PATH . "includes/" . $pathDir);
     spl_autoload_extensions('.class.php');
     spl_autoload($path[$arrCount]);
 }
 public static function register()
 {
     self::$corePath = realpath(dirname(__FILE__)) . '/';
     self::$frameworkPath = self::$corePath . 'framework/';
     self::$libsPath = self::$corePath . 'libraries/';
     spl_autoload_extensions('.php');
     spl_autoload_register(array(__CLASS__, 'autoload'));
     self::registerSmarty();
     self::registerSpyc();
     self::registerRandom();
 }
示例#18
0
 /**
  * Create instance and configure autoloader
  *
  * @param mixed    $path     Path to class directory or boolean to include current path
  * @param Callable $callback Function to call to autoload classes
  * @param array    $exts     Array of extensions to use when searching for class files
  */
 public function __construct(callable $callback, $path = false, array $exts = array('.php'))
 {
     $this->_autoloader = $callback;
     if (is_string($path)) {
         set_include_path(realpath($path) . PATH_SEPARATOR . get_include_path());
     } elseif ($path === true) {
         set_include_path(dirname(dirname(__DIR__)) . PATH_SEPARATOR . get_include_path());
     }
     spl_autoload_extensions(join(',', $exts));
     spl_autoload_register($this);
 }
示例#19
0
 /**
  * Initialise some standard things for any invocation of a page
  *
  * @return void
  */
 public static function initialise()
 {
     error_reporting(E_ALL | E_STRICT);
     /*
      * Setup the autoloader
      */
     $dir = dirname(dirname(__DIR__));
     set_include_path(implode(PATH_SEPARATOR, array(implode(DIRECTORY_SEPARATOR, array($dir, 'class')), implode(DIRECTORY_SEPARATOR, array($dir, 'class/support')), implode(DIRECTORY_SEPARATOR, array($dir, 'class/models')), implode(DIRECTORY_SEPARATOR, array($dir, 'lib')), get_include_path())));
     spl_autoload_extensions('.php');
     spl_autoload_register();
     include $dir . '/vendor/autoload.php';
 }
示例#20
0
文件: app.php 项目: spirlici/spcms
 /**
  * Register autoloading for classes
  */
 public function registerAutoload()
 {
     // firstly include vendor autoload
     include BASEDIR . 'vendor' . DS . 'autoload.php';
     // Classes from APPDIR/classes/ directory
     set_include_path(get_include_path() . PATH_SEPARATOR . APPDIR . 'classes' . DS);
     // all classes from the APPDIR.'classes' directory must have extension '.class.php'
     spl_autoload_extensions('.class.php');
     // all class files must lowercase name to avoid problems with case sensitivity
     spl_autoload_register(function ($class_name) {
         spl_autoload(strtolower($class_name));
     });
 }
示例#21
0
 private function __construct()
 {
     $this->root = dirname(dirname(__FILE__)) . '/';
     spl_autoload_register(null, false);
     spl_autoload_extensions('.php');
     spl_autoload_register(array($this, 'cached'));
     spl_autoload_register(array($this, 'library'));
     spl_autoload_register(array($this, 'model'));
     spl_autoload_register(array($this, 'event'));
     spl_autoload_register(array($this, 'controller'));
     spl_autoload_register(array($this, 'driver'));
     $this->cache = apc_fetch('lazyLoader_cache');
 }
 public function __construct()
 {
     $this->CI =& get_instance();
     $this->loadConfig();
     $this->metadataConfiguration = self::createMetadataConfiguration($this->config);
     $this->createEntityManager();
     if ($this->config['dev_mode']) {
         $this->debugStack = new Doctrine\DBAL\Logging\DebugStack();
         $this->em->getConnection()->getConfiguration()->setSQLLogger($this->debugStack);
     }
     /** Add autoload for entities */
     spl_autoload_extensions('.php');
     spl_autoload_register(array($this, 'autoLoad'));
 }
function classLoader($className)
{
    $extensions = explode(',', spl_autoload_extensions());
    $directories = explode(PATH_SEPARATOR, get_include_path());
    foreach ($directories as $directory) {
        foreach ($extensions as $extension) {
            $classFile = $directory . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, explode('\\', $className)) . $extension;
            if (file_exists($classFile) && is_readable($classFile)) {
                require_once $classFile;
                return $classFile;
            }
        }
    }
}
示例#24
0
 /**
  * The constructor for this class. It is private because this is a singleton that should only
  * be instatiated once by itself.
  * @param Array $classDirs - array of all the folder paths to look in for classes.
  * @param Closure $conversionFunction - (optional) provide An annonymous function to convert 
  *                                      a given class name to the filename that it can be loaded 
  *                                      from. If not provided then the Zend standard naming
  *                                      convention is assumed.
  * @return void
  */
 public function __construct($classDirs, Closure $conversionFunction = null)
 {
     $this->m_classDirs = $classDirs;
     # specify your model/utility/library folders here
     # If a conversion function has not been specified, then use our own default.
     if ($conversionFunction === null) {
         $conversionFunction = function ($className) {
             return Autoloader::convertClassNameToFileName($className);
         };
         $this->m_conversionFunction = $conversionFunction;
     } else {
         $this->m_conversionFunction = $conversionFunction;
     }
     // Specify extensions that may be loaded
     spl_autoload_extensions('.php');
     spl_autoload_register(array($this, 'loaderCallback'));
 }
示例#25
0
/**
 * Does the same as spl_autoload, but without lowercasing
 */
function SPL_autoload_suxx($name)
{
    $rc = FALSE;
    $exts = explode(',', spl_autoload_extensions());
    $sep = substr(PHP_OS, 0, 3) == 'Win' ? ';' : ':';
    $paths = explode($sep, ini_get('include_path'));
    foreach ($paths as $path) {
        foreach ($exts as $ext) {
            $file = $path . DIRECTORY_SEPARATOR . $name . $ext;
            if (is_readable($file)) {
                require_once $file;
                $rc = $file;
                break;
            }
        }
    }
    return $rc;
}
示例#26
0
function uber_autoloader($className)
{
    $namespace = '';
    $dir = '';
    $namespaced_class = '';
    $class_prefix = 'class.';
    $dir_separator = '/';
    $theme_dir = 'wp-content/themes/bones/library';
    $FQCN = '';
    $path_components = explode("\\", $className);
    $namespace = strtolower(array_shift($path_components));
    $directory = array_shift($path_components);
    $namespaced_class = current($path_components);
    $FQCN = $theme_dir . '/' . $namespace . '/' . $directory . '/' . $class_prefix . $namespaced_class . spl_autoload_extensions();
    print '<pre>';
    var_dump($FQCN);
    print '</pre>';
    include $FQCN;
}
 private function __construct()
 {
     /*** nullify any existing autoloads ***/
     spl_autoload_register(null, false);
     /*** specify extensions that may be loaded ***/
     spl_autoload_extensions('.php, .class.php');
     /*** register the loader functions ***/
     // $this->loadConstants();
     spl_autoload_register(array($this, 'loadDatabases'));
     spl_autoload_register(array($this, 'loadConfigurations'));
     spl_autoload_register(array($this, 'loadConstants'));
     spl_autoload_register(array($this, 'loadMessages'));
     spl_autoload_register(array($this, 'loadInterfaces'));
     spl_autoload_register(array($this, 'loadLibraries'));
     spl_autoload_register(array($this, 'loadFactories'));
     spl_autoload_register(array($this, 'loadActions'));
     spl_autoload_register(array($this, 'loadDatahandlers'));
     spl_autoload_register(array($this, 'loadViews'));
     spl_autoload_register(array($this, 'loadVendors'));
 }
示例#28
0
function linux_namespaces_autoload($class_name)
{
    $class_name = implode(DIRECTORY_SEPARATOR, explode('\\', $class_name));
    static $extensions = array();
    if (empty($extensions)) {
        $extensions = array_map('trim', explode(',', spl_autoload_extensions()));
    }
    static $include_paths = array();
    if (empty($include_paths)) {
        $include_paths = explode(PATH_SEPARATOR, get_include_path());
    }
    foreach ($include_paths as $path) {
        $path .= DIRECTORY_SEPARATOR !== $path[strlen($path) - 1] ? DIRECTORY_SEPARATOR : '';
        foreach ($extensions as $extension) {
            $file = $path . $class_name . $extension;
            if (file_exists($file) && is_readable($file)) {
                require $file;
                return;
            }
        }
    }
}
示例#29
0
 /**
  * Registers the autoloader
  * @return void
  */
 public static function register()
 {
     $includepaths = explode(PATH_SEPARATOR, get_include_path());
     if (!in_array(NIMBLES_PATH, $includepaths)) {
         set_include_path(NIMBLES_PATH . PATH_SEPARATOR . get_include_path());
     }
     spl_autoload_extensions('.php');
     /**
      * Add support for lower case build mode
      */
     if ('loader.php' === basename(__FILE__)) {
         spl_autoload_register('Nimbles\\Core\\Loader::autoload', false, true);
         spl_autoload_register('spl_autoload', false, true);
     } else {
         if (function_exists('spl_autoload_case_sensitive')) {
             spl_autoload_case_sensitive(true);
             spl_autoload_register('spl_autoload', false, true);
         } else {
             spl_autoload_register('Nimbles\\Core\\Loader::autoload', false, true);
         }
     }
 }
示例#30
0
 private static function get_extensions()
 {
     if (isset(self::$extensions)) {
         return self::$extensions;
     } else {
         self::$extensions = explode(',', spl_autoload_extensions());
         $extensions = array();
         for ($i = 0, $max = count(self::$extensions); $i < $max; $i++) {
             if (preg_match('/^[^.].+=>\\..+$/', self::$extensions[$i])) {
                 $e = explode('=>', self::$extensions[$i]);
                 $label = $e[0];
                 $extension = $e[1];
                 $extensions[$label] = $extension;
                 unset($extension, $label, $e);
             } elseif (preg_match('/^\\..+$/', self::$extensions[$i])) {
                 $extensions[] = self::$extensions[$i];
             }
         }
         self::$extensions = $extensions;
         return $extensions;
     }
 }