當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Loader\AutoloaderFactory類代碼示例

本文整理匯總了PHP中Zend\Loader\AutoloaderFactory的典型用法代碼示例。如果您正苦於以下問題:PHP AutoloaderFactory類的具體用法?PHP AutoloaderFactory怎麽用?PHP AutoloaderFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了AutoloaderFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createService

 /**
  * Creates and returns the module manager
  *
  * Instantiates the default module listeners, providing them configuration
  * from the "module_listener_options" key of the ApplicationConfig
  * service. Also sets the default config glob path.
  *
  * Module manager is instantiated and provided with an EventManager, to which
  * the default listener aggregate is attached. The ModuleEvent is also created
  * and attached to the module manager.
  *
  * @param ServiceLocatorInterface $serviceLocator Service Manager
  *
  * @return ModuleManager
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $moduleCollection = new ModuleCollection();
     $modules = $moduleCollection->getModules();
     $array = array();
     $autoloader = AutoloaderFactory::getRegisteredAutoloader(AutoloaderFactory::STANDARD_AUTOLOADER);
     foreach ($modules as $module) {
         $array[] = $module->getName();
         $path = GC_APPLICATION_PATH . '/library/Modules/' . $module->getName();
         if (file_exists($path) === false) {
             $path = GC_APPLICATION_PATH . '/extensions/Modules/' . $module->getName();
         }
         $autoloader->registerNamespace($module->getName(), $path);
     }
     $autoloader->register();
     $application = $serviceLocator->get('Application');
     $configuration = $serviceLocator->get('ApplicationConfig');
     $configuration['module_listener_options']['module_paths'] = array('./library/Modules', './extensions/Modules');
     $listenerOptions = new Listener\ListenerOptions($configuration['module_listener_options']);
     $defaultListeners = new Listener\DefaultListenerAggregate($listenerOptions);
     $serviceListener = new Listener\ServiceListener($serviceLocator);
     $this->prepareServices($serviceListener, $serviceLocator);
     $moduleManager = new ModuleManager($array, $application->getEventManager());
     $moduleManager->getEventManager()->attachAggregate($defaultListeners);
     $moduleManager->getEventManager()->attachAggregate($serviceListener);
     $moduleManager->loadModules();
     $config = $moduleManager->getEvent()->getConfigListener()->getMergedConfig(false);
     $this->prepareConfig($serviceLocator, $config);
     foreach ($moduleManager->getLoadedModules() as $module) {
         if (method_exists($module, 'onBootstrap')) {
             $module->onBootstrap($application->getMvcEvent());
         }
     }
     return $moduleManager;
 }
開發者ID:gotcms,項目名稱:gotcms,代碼行數:50,代碼來源:ModuleManagerFactory.php

示例2: initAutoloader

 protected static function initAutoloader()
 {
     $vendorPath = static::findParentPath('vendor');
     if (file_exists($vendorPath . '/autoload.php')) {
         $loader = (include $vendorPath . '/autoload.php');
     }
     if (class_exists('Zend\\Loader\\AutoloaderFactory')) {
         return;
     }
     $zf2Path = false;
     if (getenv('ZF2_PATH')) {
         // Support for ZF2_PATH environment variable
         $zf2Path = getenv('ZF2_PATH');
     } elseif (get_cfg_var('zf2_path')) {
         // Support for zf2_path directive value
         $zf2Path = get_cfg_var('zf2_path');
     }
     if ($zf2Path) {
         if (isset($loader)) {
             $loader->add('Zend', $zf2Path);
             $loader->add('ZendXml', $zf2Path);
         } else {
             include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
             Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true)));
         }
     }
 }
開發者ID:antarus,項目名稱:mystra-pve,代碼行數:27,代碼來源:Bootstrap.php

示例3: initAutoloader

 protected static function initAutoloader()
 {
     $vendorPath = static::findParentPath('vendor');
     // Include composer autoloader
     // TODO Make a Zend PSR-4 autoloader?
     include $vendorPath . '/autoload.php';
     // Locate ZF2 path.
     $zf2Path = getenv('ZF2_PATH');
     if (!$zf2Path) {
         if (defined('ZF2_PATH')) {
             $zf2Path = ZF2_PATH;
         } elseif (is_dir($vendorPath . '/ZF2/library')) {
             $zf2Path = $vendorPath . '/ZF2/library';
         } elseif (is_dir($vendorPath . '/zendframework/zendframework/library')) {
             $zf2Path = $vendorPath . '/zendframework/zendframework/library';
         }
     }
     if (!$zf2Path) {
         throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.');
     }
     // Set up ZF2 autoloader to find itself and the test classes.
     include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
     $autoloadOptions = array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array(__NAMESPACE__ => __DIR__)));
     AutoloaderFactory::factory($autoloadOptions);
 }
開發者ID:bvarent,項目名稱:doc-block-tags,代碼行數:25,代碼來源:Bootstrap.php

示例4: autoload

 /**
  * @throws \Exception
  */
 protected static function autoload()
 {
     if (file_exists('vendor/autoload.php')) {
         $loader = (require 'vendor/autoload.php');
     }
     // the entire application is based on Composer loader, but just in case
     // let's instantiate the loader if I can't find Composer's ClassLoader
     if (empty($loader)) {
         switch (true) {
             case file_exists('vendor/zendframework/zendframework/library/Zend/Loader/AutoloaderFactory.php'):
                 require_once 'vendor/zendframework/zendframework/library/Zend/Loader/AutoloaderFactory.php';
                 \Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'fallback_autoloader' => true)));
                 require_once 'vendor/zendframework/zendframework/library/Zend/Loader/StandardAutoloader.php';
                 $loader = \Zend\Loader\AutoloaderFactory::getRegisteredAutoloader('Zend\\Loader\\StandardAutoloader');
                 break;
                 // @TODO: case file_exists('path/to/Symfony/Loader.php') / Implement when you'll need it
             // @TODO: case file_exists('path/to/Symfony/Loader.php') / Implement when you'll need it
             default:
                 throw new \Exception('Could not find neither Zend nor Composer or Symfony libraries for creating a class loader!');
         }
     }
     // register Netis only. The real class loader will be instantiated inside the Application classes
     switch (true) {
         case $loader instanceof \Zend\Loader\SplAutoloader:
             $loader->registerPrefix('Netis', 'vendor/athemcms/Netis/library/Netis');
             break;
         case $loader instanceof \Composer\Autoload\ClassLoader:
             $loader->add('Netis', 'vendor/athemcms/netis/library');
             break;
             // @TODO: Implement Symfony when you'll need it as well :D
         // @TODO: Implement Symfony when you'll need it as well :D
         default:
             throw new \Exception('No Loader detected!');
     }
 }
開發者ID:athemcms,項目名稱:netis,代碼行數:38,代碼來源:ApplicationFactory.php

示例5: initAutoloader

 protected static function initAutoloader()
 {
     $vendorPath = static::findParentPath('vendor');
     $zf2Path = getenv('ZF2_PATH');
     if (!$zf2Path) {
         if (defined('ZF2_PATH')) {
             $zf2Path = ZF2_PATH;
         } elseif (is_dir($vendorPath . '/ZF2/library')) {
             $zf2Path = $vendorPath . '/ZF2/library';
         } elseif (is_dir($vendorPath . '/zendframework/zendframework/library')) {
             $zf2Path = $vendorPath . '/zendframework/zendframework/library';
         }
     }
     if (!$zf2Path) {
         throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or' . ' define a ZF2_PATH environment variable.');
     }
     if (file_exists($vendorPath . '/autoload.php')) {
         include $vendorPath . '/autoload.php';
     }
     include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
     $namespaces = array(__NAMESPACE__ => __DIR__);
     $modulePath = self::findParentPath('module');
     if ($handle = opendir(static::findParentPath('src/module'))) {
         while (false !== ($file = readdir($handle))) {
             if (substr($file, 0, 1) != '.') {
                 $namespaces[$file] = $modulePath . '/' . $file . '/src/' . $file;
                 $namespaces[$file . 'Test'] = $modulePath . '/' . $file . '/test/' . $file . 'Test';
             }
         }
         closedir($handle);
     }
     AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => $namespaces)));
 }
開發者ID:andreas-serlo,項目名稱:athene2,代碼行數:33,代碼來源:Bootstrap.php

示例6: initAutoloader

    protected static function initAutoloader()
    {
        $vendorPath = static::findParentPath('vendor');

        if (is_readable($vendorPath . '/autoload.php')) {
            $loader = include $vendorPath . '/autoload.php';
            return;
        }

        $zf2Path = getenv('ZF2_PATH') ?: (defined('ZF2_PATH') ? ZF2_PATH : (is_dir($vendorPath . '/ZF2/library') ? $vendorPath . '/ZF2/library' : false));

        if (!$zf2Path) {
            throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.');
        }

        if (isset($loader)) {
            $loader->add('Zend', $zf2Path . '/Zend');
        } else {
            include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
            AutoloaderFactory::factory(array(
                'Zend\Loader\StandardAutoloader' => array(
                    'autoregister_zf' => true,
                    'namespaces' => array(
                        'ZF\Configuration' => __DIR__ . '/../src/',
                        __NAMESPACE__ => __DIR__,
                    ),
                ),
            ));
        }
    }
開發者ID:jbarentsen,項目名稱:drb,代碼行數:30,代碼來源:Bootstrap.php

示例7: initAutoloader

 protected static function initAutoloader()
 {
     $vendorPath = static::findParentPath('vendor');
     if (file_exists($vendorPath . '/autoload.php')) {
         include $vendorPath . '/autoload.php';
     }
     AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array(__NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__))));
 }
開發者ID:uthando-cms,項目名稱:uthando-news,代碼行數:8,代碼來源:Bootstrap.php

示例8: index7Action

 public function index7Action()
 {
     \Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\ClassMapAutoloader' => array(LIBRARY_PATH . '/../../../Autoloader/Autoloader.php', LIBRARY_PATH . '/../../../Autoloader/classmap.php')));
     $student = new \Database\Student();
     $teacher = new \Database\Teacher();
     $worker = new \Database\Oracle\Worker();
     $upload = new \File\Abc\Upload();
     return false;
 }
開發者ID:htam261,項目名稱:zendskeleton,代碼行數:9,代碼來源:AutoloaderController.php

示例9: initAutoloader

 protected static function initAutoloader()
 {
     $vendorPath = static::findParentPath('vendor');
     if (file_exists($vendorPath . '/autoload.php')) {
         include $vendorPath . '/autoload.php';
     }
     include $vendorPath . '/zendframework/zend-loader/src/AutoloaderFactory.php';
     AutoloaderFactory::factory(['Zend\\Loader\\StandardAutoloader' => ['autoregister_zf' => true, 'namespaces' => [__NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__]]]);
 }
開發者ID:saeven,項目名稱:phpspec-zf2,代碼行數:9,代碼來源:ZendFramework2Extension.php

示例10: __invoke

 /**
  * @param \Zend\Module\ModuleEvent $e
  * @return void
  */
 public function __invoke(ModuleEvent $e)
 {
     $module = $e->getModule();
     if (!$module instanceof AutoloaderProvider) {
         return;
     }
     $autoloaderConfig = $module->getAutoloaderConfig();
     AutoloaderFactory::factory($autoloaderConfig);
 }
開發者ID:rikaix,項目名稱:zf2,代碼行數:13,代碼來源:AutoloaderListener.php

示例11: __invoke

 /**
  * @param  ModuleEvent $e
  * @return void
  */
 public function __invoke(ModuleEvent $e)
 {
     $module = $e->getModule();
     if (!$module instanceof AutoloaderProviderInterface && !method_exists($module, 'getAutoloaderConfig')) {
         return;
     }
     $autoloaderConfig = $module->getAutoloaderConfig();
     AutoloaderFactory::factory($autoloaderConfig);
 }
開發者ID:Baft,項目名稱:Zend-Form,代碼行數:13,代碼來源:AutoloaderListener.php

示例12: initAutoloader

 protected static function initAutoloader()
 {
     \Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true)));
     $smConfig = new ServiceManagerConfig([]);
     $serviceManager = new ServiceManager();
     $smConfig->configureServiceManager($serviceManager);
     $serviceManager->setService('ApplicationConfig', include __DIR__ . '/config/application.config.php');
     $serviceManager->get('ModuleManager')->loadModules();
     static::$serviceManager = $serviceManager;
 }
開發者ID:buse974,項目名稱:address,代碼行數:10,代碼來源:bootstrap.php

示例13: initAutoloader

 protected static function initAutoloader()
 {
     $vendorPath = static::findParentPath('vendor');
     if (is_readable($vendorPath . '/autoload.php')) {
         $loader = (include $vendorPath . '/autoload.php');
     } else {
         throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install`.');
     }
     AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array(__NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__))));
 }
開發者ID:leloulight,項目名稱:Cornerstone,代碼行數:10,代碼來源:Bootstrap.php

示例14: initAutoloader

 public static function initAutoloader()
 {
     $vendorPath = static::findParentPath('vendor');
     if (file_exists($vendorPath . '/autoload.php')) {
         include $vendorPath . '/autoload.php';
     }
     if (!class_exists('Zend\\Loader\\AutoloaderFactory')) {
         throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install`');
     }
     AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array('ActionInjections' => self::findParentPath('src') . '/ActionInjections'))));
 }
開發者ID:BulgariaPHP,項目名稱:zf-action-injections,代碼行數:11,代碼來源:Bootstrap.php

示例15: execute

 public static function execute()
 {
     include 'init_autoloader.php';
     define('ZF2_PATH', realpath('vendor/zendframework/zendframework/library'));
     $path = array(ZF2_PATH, get_include_path());
     set_include_path(implode(PATH_SEPARATOR, $path));
     require_once 'Zend/Loader/AutoloaderFactory.php';
     require_once 'Zend/Loader/StandardAutoloader.php';
     // setup autoloader
     AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array(StandardAutoloader::AUTOREGISTER_ZF => true, StandardAutoloader::ACT_AS_FALLBACK => false, StandardAutoloader::LOAD_NS => array('Admin\\Infra' => getcwd() . '/module/Admin/src/Admin/Infra', 'Admin\\Domain' => getcwd() . '/module/Admin/src/Admin/Domain'))));
 }
開發者ID:rzorzal,項目名稱:MyZend2Skeleton,代碼行數:11,代碼來源:Bootstrap.php


注:本文中的Zend\Loader\AutoloaderFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。