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))); } } }
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); }
/** * @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!'); } }
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__, ), ), )); } }
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))); }
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__)))); }
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__]]]); }
/** * @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); }
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; }
/** * @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); }
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; }
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__)))); }
protected 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(['Zend\\Loader\\StandardAutoloader' => ['autoregister_zf' => true, 'namespaces' => [__NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__]]]); }
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')))); }
protected function registerZf2Autoloader() { $options = $this->getOptions(); if (!empty($options['zf2_path'])) { include_once $options['zf2_path'] . '/Zend/Loader/AutoloaderFactory.php'; } if (!class_exists('Zend\\Loader\\AutoloaderFactory', true)) { throw new DomainException('Option "zf2Path" was not provided'); } AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true))); }
public function index06Action() { echo "<h3 style='color:red;font-weight:bold'>" . __METHOD__ . "</h3>"; \Zend\Loader\AutoloaderFactory::factory(array("\\Zend\\Loader\\ClassMapAutoloader" => array(LIB_PATH . "/ClassMap/AutoLoader.php", LIB_PATH . "/AutoLoader2.php"))); $student = new \Database\Student(); $teacher = new \Database\Teacher(); $people = new \Database\basetada\People(); $sontung_m = new \Art\Singer(); $sender = new \Mail_Sender(); return false; }
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')))); }
protected static function initAutoloader() { $vendorPath = static::findParentPath('vendor'); $loader = (include $vendorPath . '/autoload.php'); \Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array('Mock' => __DIR__ . '/Mock')))); $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; }
private function loadLibrary() { /* * InoOicClient library store a state object in session. * When the session is first opened in pre.php the library is not yet loaded. * PHP is not able to unserialize the object and you get a __PHP_Incomplete_Class object. * To prevent that, we close the session, load the library and then reopen the session. */ session_write_close(); AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('namespaces' => array('InoOicClient' => '/usr/share/php/InoOicClient/')))); session_start(); }
public static function execute() { chdir(dirname(__DIR__ . '/../../../..')); 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('Core' => __DIR__ . '/../../../module/Core/src/Core')))); }
public static function go() { //@todo verificar se não existe uma constante indicando o diretório raiz do projeto chdir(dirname(__DIR__ . '/../../../../')); 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('Core' => getcwd() . '/module/Core/src/Core')))); }
protected static function initAutoloader() { $vendorPath = static::findParentPath('vendor'); $zf2Path = "/var/www/html/zf2/qluser_zend/vendor"; 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'; AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array(__NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__)))); }
/** * */ protected static function initAutoloader() { $vendorPath = '/ginosi/incubator/api'; $zf2Path = '/ginosi/incubator/api/zendframework'; if (!is_dir($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/src/AutoloaderFactory.php'; AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array(__NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__)))); }
protected static function initAutoloader() { $vendorPath = static::findParentPath('vendor'); if (is_readable($vendorPath . '/autoload.php')) { $loader = (include $vendorPath . '/autoload.php'); } else { $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.'); } include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; } AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array(__NAMESPACE__ => TEST_WORKING_DIR . '/' . __NAMESPACE__)))); }
/** * Initialize autoloader */ protected static function initAutoloader() { $vendorPath = APPLICATION_ROOT . '/vendor'; if (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'; AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array(__NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__)))); }
public static function go() { $zf2Path = realpath(defined('ZF2_PATH') ? ZF2_PATH : (getenv('ZF2_PATH') ?: '/zf2/library')); // parent directory of this module $zf2ModulesPaths = dirname(dirname(__DIR__)) . PATH_SEPARATOR; // other paths to find modules one $zf2ModulesPaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: realpath(__DIR__ . '/../../../vendor'); // autoload ZF2 include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true))); // use ModuleManager to load this module and it's dependencies $config = array('modules' => array('SpeckPI', 'SpeckCart', 'ZfcBase'), 'module_listener_options' => array('config_glob_paths' => array(__DIR__ . '/config/autoload/{,*.}{global,local}.php'), 'config_cache_enabled' => false, 'module_paths' => explode(PATH_SEPARATOR, $zf2ModulesPaths))); $app = Application::init($config); self::$serviceManager = $app->getServiceManager(); }
/** * Set up application environment, optionally run the application * * This sets up the PHP environment and autoloaders, loads the provided * module and optionally runs the MVC application. The default behavior for * the $run option depends on the module. This should rarely need to be * overridden except for testing. * * @param string $module Module to load * @param bool $run Run the application after initialization. Default: TRUE * @codeCoverageIgnore */ public static function init($module, $run = true) { // Set up PHP environment. session_cache_limiter('nocache'); // Default headers to prevent caching // Evaluate locale from HTTP header. Affects translations, date/time rendering etc. \Locale::setDefault(\Locale::acceptFromHttp(@$_SERVER['HTTP_ACCEPT_LANGUAGE'])); // Set up autoloader for ZF classes require_once 'Zend/Loader/AutoloaderFactory.php'; \Zend\Loader\AutoloaderFactory::factory(array('\\Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true))); $application = \Zend\Mvc\Application::init(array('modules' => array($module), 'module_listener_options' => array('module_paths' => array('Console' => self::getPath('module/Console/Console'), 'Database' => self::getPath('module/Database'), 'Export' => self::getPath('module/Export'), 'Library' => self::getPath('module/Library'), 'Model' => self::getPath('module/Model'), 'PackageBuilder' => self::getPath('module/PackageBuilder'), 'Protocol' => self::getPath('module/Protocol'), 'DatabaseManager' => self::getPath('module/DatabaseManager'))))); self::$_serviceManager = $application->getServiceManager(); if ($run) { $application->run(); } }
/** * Initialize Autoloader * @throws RuntimeException */ private static function initAutoloader() { if (is_readable($sAutoloadPath = static::findParentPath('vendor') . DIRECTORY_SEPARATOR . 'autoload.php')) { include $sAutoloadPath; } if (!class_exists('Zend\\Loader\\AutoloaderFactory')) { throw new \RuntimeException('Unable to load ZF2. Install required libraries through `composer`'); } $oReflectionClass = new \ReflectionClass(get_called_class()); $sNamespace = $oReflectionClass->getNamespaceName(); $aNamespaces = array(); if (is_dir($sFixturesDir = self::getTestDir() . DIRECTORY_SEPARATOR . 'Fixture')) { $aNamespaces[$sNamespace . '\\Fixture'] = $sFixturesDir; } $aNamespaces[$sNamespace] = self::getTestDir() . DIRECTORY_SEPARATOR . $sNamespace; \Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => $aNamespaces))); }
protected static function initAutoloader() { $vendorPath = static::findParentPath('vendor'); if (is_readable($vendorPath . '/autoload.php')) { $loader = (include $vendorPath . '/autoload.php'); } $zf2Path = getenv('ZF2_PATH'); if (!$zf2Path) { $zf2Path = "../../zendframework/library"; } 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(__NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__)))); } }
/** * Инициализация автозагрузчика * * @return void * * @throws RuntimeException */ protected static function initAutoloader() { $vendorPath = static::findParentPath('vendor'); if (is_readable($vendorPath . '/autoload.php')) { /** @noinspection PhpIncludeInspection */ include $vendorPath . '/autoload.php'; } if (!class_exists(AutoloaderFactory::class)) { throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); } try { AutoloaderFactory::factory([StandardAutoloader::class => ['autoregister_zf' => true, 'namespaces' => ['OldTown\\Workflow\\Designer\\Server' => __DIR__ . '/../../src/', __NAMESPACE__ => __DIR__ . '/tests/', 'OldTown\\Workflow\\Designer\\Server\\PhpUnit\\Utils' => __DIR__ . '/utils']], ClassMapAutoloader::class => [[Paths::class => __DIR__ . DIRECTORY_SEPARATOR . 'Paths.php']]]); } catch (\Exception $e) { $errMsg = 'Ошибка инициации автолоадеров'; throw new RuntimeException($errMsg, $e->getCode(), $e); } }