public static function initAutoloader() { if (file_exists('vendor/autoload.php')) { $loader = (include 'vendor/autoload.php'); } if (class_exists('Zend\\Loader\\AutoloaderFactory')) { return; } $zf2Path = false; if (is_dir('vendor/ZF2/library')) { $zf2Path = 'vendor/ZF2/library'; } elseif (getenv('ZF2_PATH')) { // Support for ZF2_PATH environment variable or git submodule $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))); } } if (!class_exists('Zend\\Loader\\AutoloaderFactory')) { throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); } }
<?php /** * This reproduction script shall accompany the issue reported at * http://framework.zend.com/issues/browse/ZF-143 * * Assumptions: * ZF2 beta 2 * * Result: * This script should exit without throwing an exception or output */ // Ensure ZF is on the include path set_include_path(implode(PATH_SEPARATOR, array(realpath(__DIR__ . '/../vendor/Zend/library'), get_include_path()))); // Setup autoloader require_once 'Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('fallback_autoloader' => true))); // Create a TreeRouteStack with a parent & child route $router = new Zend\Mvc\Router\Http\TreeRouteStack(); $router->addRoutes(array('core' => array('type' => 'segment', 'options' => array('route' => '/root/:param1', 'defaults' => array('controller' => 'Contents\\Controller\\ContentsController', 'schemas' => array('contents/1' => 'Contents\\View\\Contents1'))), 'may_terminate' => true, 'child_routes' => array('optional-segment' => array('type' => 'segment', 'options' => array('route' => '/child[/:param2]', 'defaults' => array('controller' => 'MyModule\\Controllers\\MyControllerController', 'action' => 'index'))))))); // Setup parameters with one param defined and the other set to NULL (does not exist) $routeParams = array('param1' => 'unique-identifier', 'param2' => NULL); // Attempt to assemble a path that would match the child route without the optional parameter $assembledRoute = $router->assemble($routeParams, array('name' => 'core/optional-segment')) . "\n"; // Expected: $assembledRoute = '/root/unique-identifier/child'
<?php chdir(__DIR__); $path = dirname(__DIR__); require_once "{$path}/vendor/ZendFramework/library/Zend/Loader/AutoloaderFactory.php"; Zend\Loader\AutoloaderFactory::factory(); $appConfig = (include "{$path}/config/application.config.php"); $listenerOptions = new Zend\Module\Listener\ListenerOptions($appConfig['module_listener_options']); $defaultListeners = new Zend\Module\Listener\DefaultListenerAggregate($listenerOptions); $defaultListeners->getConfigListener()->addConfigGlobPath("{$path}/config/autoload/*.config.php"); $moduleManager = new Zend\Module\Manager($appConfig['modules']); $moduleManager->events()->attachAggregate($defaultListeners); $moduleManager->loadModules(); // Create application, bootstrap, and run $bootstrap = new Zend\Mvc\Bootstrap($defaultListeners->getConfigListener()->getMergedConfig()); $application = new Zend\Mvc\Application(); $bootstrap->bootstrap($application); $application->run()->send();
<?php // Composer autoloading if (file_exists('vendor/autoload.php')) { $loader = (include 'vendor/autoload.php'); } if (is_dir('vendor/ZF2/library')) { $zf2Path = 'vendor/ZF2/library'; } elseif (getenv('ZF2_PATH')) { // Support for ZF2_PATH environment variable or git submodule $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); } else { include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespace' => array('ZendServerWebApi' => __DIR__ . '/vendor/ZendServerWebApi/src')))); } } if (!class_exists('Zend\\Loader\\AutoloaderFactory')) { throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); }
<?php /** * NextCMS (http://nextcms.org) * * @link https://github.com/nghuuphuoc/nextcms * @author Nguyen Huu Phuoc <*****@*****.**> * @copyright Copyright (c) 2013 NextCMS * @license MIT */ define('APP_VENDOR_DIR', dirname(__DIR__) . '/vendor'); if (file_exists(APP_VENDOR_DIR . '/autoload.php')) { $loader = (include APP_VENDOR_DIR . '/autoload.php'); } if (isset($loader)) { $loader->add('Zend', APP_VENDOR_DIR . '/Zend'); } else { include APP_VENDOR_DIR . '/Zend/Loader/StandardAutoloader.php'; include APP_VENDOR_DIR . '/Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(['Zend\\Loader\\StandardAutoloader' => ['autoregister_zf' => true, 'namespaces' => []]]); } set_include_path(PATH_SEPARATOR . APP_VENDOR_DIR . PATH_SEPARATOR . get_include_path()); if (!class_exists('Zend\\Loader\\AutoloaderFactory')) { throw new RuntimeException('Cannot load ZF2 library!'); }
<?php //ad562ed675cf746e886308b57144220f8e include 'define.php'; include LIBRARY_PATH . '/Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array('ZendVN' => LIBRARY_PATH . '/ZendVN', 'ZendGData' => LIBRARY_PATH . '/ZendGData', 'Block' => APPLICATION_PATH . '/ad562ed675cf746e886308b57144220f8e_block', 'Sidebar' => APPLICATION_PATH . '/ad562ed675cf746e886308b57144220f8e_sidebar'), 'prefixes' => array('HTMLPurifier' => LIBRARY_PATH . '/HTMLPurifier')))); if (!class_exists('Zend\\Loader\\AutoloaderFactory')) { throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); } // Run the application! Zend\Mvc\Application::init(require 'ad562ed675cf746e886308b57144220f8e_config/application.config.php')->run();
public function setUp() { $this->_module = new Module(); Zend\Loader\AutoloaderFactory::factory($this->_module->getAutoloaderConfig()); }
<?php error_reporting(E_ALL); // Check version if (version_compare(phpversion(), '5.3.3', '<')) { printf('PHP 5.3.3 is required, you have %s', phpversion()); exit(1); } defined('EVA_ROOT_PATH') || define('EVA_ROOT_PATH', __DIR__ . '/../..'); defined('EVA_PUBLIC_PATH') || define('EVA_PUBLIC_PATH', __DIR__ . '/..'); defined('EVA_LIB_PATH') || define('EVA_LIB_PATH', __DIR__ . '/../../vendor'); defined('EVA_MODULE_PATH') || define('EVA_MODULE_PATH', __DIR__ . '/../../module'); defined('EVA_CONFIG_PATH') || define('EVA_CONFIG_PATH', __DIR__ . '/../../config'); /** Public functions */ function p($r, $usePr = false) { if ($usePr || false === method_exists('\\Zend\\Debug', 'dump')) { echo '<pre>' . print_r($r, true) . '</pre>'; return; } \Zend\Debug::dump($r); } set_include_path(implode(PATH_SEPARATOR, array('.', EVA_LIB_PATH, get_include_path()))); //require_once 'Eva/Loader/AutoloaderFactory.php'; require_once EVA_LIB_PATH . '/Zend/library/Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true))); $loader = Zend\Loader\AutoloaderFactory::getRegisteredAutoloaders(); $loader = $loader[Zend\Loader\AutoloaderFactory::STANDARD_AUTOLOADER]; $loader->registerNamespace('Eva\\', EVA_PUBLIC_PATH . '/../vendor/Eva');
<?php Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array(Zend\Loader\StandardAutoloader::LOAD_NS => array('ZfPhpcrOdmSample' => __DIR__ . '/src/ZfPhpcrOdmSample'))));
<?php chdir(dirname(__DIR__)); define('APP_ROOT', dirname(__DIR__) . '/'); require 'init_autoloader.php'; Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('namespaces' => array('PhpIdServer' => 'module/PhpIdServer/src/PhpIdServer/')))); //-- function _dump($value) { error_log(print_r($value, true)); }
<?php $cookieDomain = str_Replace('www.', '', $_SERVER['SERVER_NAME']); ini_set("session.cookie_domain", $cookieDomain); if (defined('ZF2')) { if (isset($loader)) { $loader->add('Zend', ZF2); $loader->add('COM', LIB); } else { include ZF2 . '/Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array('COM' => LIB . '/COM', 'Pingpp' => LIB . '/COM/Service/pingpp-php/lib')))); } } if (!class_exists('Zend\\Loader\\AutoloaderFactory')) { throw new RuntimeException('Unable to load ZF2'); }
defined('PKWK_WARNING') or define('PKWK_WARNING', false); defined('ROOT_URI') or define('ROOT_URI', dirname($_SERVER['PHP_SELF']) . '/'); defined('WWW_HOME') or define('WWW_HOME', './'); defined('COMMON_URI') or define('COMMON_URI', ROOT_URI); if (DEBUG) { error_reporting(E_ALL); // Show all errors ini_set('display_errors', 'On'); } defined('LIB_DIR') or define('LIB_DIR', realpath('./') . '/'); defined('SITE_HOME') or define('SITE_HOME', realpath('./') . '/'); define('VENDOR_DIR', realpath(SITE_HOME . '..' . DIRECTORY_SEPARATOR . 'vendor') . DIRECTORY_SEPARATOR); // Composer autoloading if (file_exists(VENDOR_DIR . 'autoload.php')) { $loader = (include VENDOR_DIR . 'autoload.php'); $loader->add('Zend', 'vendor/zendframework/zendframework/library'); } if (!class_exists('Zend\\Loader\\AutoloaderFactory')) { throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install`.'); } ///////////////////////////////////////////////// // Initilalize PukiWiki // Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('namespaces' => array('PukiWiki' => LIB_DIR . 'PukiWiki')))); ///////////////////////////////////////////////// // Load *.ini.php files and init PukiWiki require LIB_DIR . 'legacy.php'; // Defaults require LIB_DIR . 'init.php'; /* End of file main.php */ /* Location: ./wiki-common/lib/main.php */
* most users, however, feel free to configure autoloading however you'd like. */ // Composer autoloading if (file_exists('vendor/autoload.php')) { $loader = (include 'vendor/autoload.php'); } if (class_exists('Zend\\Loader\\AutoloaderFactory')) { return; } $zf2Path = false; if (is_dir('vendor/ZF2/library')) { $zf2Path = 'vendor/ZF2/library'; } elseif (getenv('ZF2_PATH')) { // Support for ZF2_PATH environment variable or git submodule $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(['Zend\\Loader\\StandardAutoloader' => ['autoregister_zf' => true]]); } } if (!class_exists('Zend\\Loader\\AutoloaderFactory')) { throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); }
<?php // Define path to application directory defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application')); // Define path to modules directory defined('MODULES_PATH') || define('MODULES_PATH', realpath(dirname(__FILE__) . '/../modules')); // Define path to library directory defined('LIBRARY_PATH') || define('LIBRARY_PATH', realpath(dirname(__FILE__) . '/../library')); // Define path to Zend Framework directory defined('ZF_PATH') || define('ZF_PATH', realpath(LIBRARY_PATH . '/ZendFramework2/library')); // Define application environment defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'); // Ensure ZF/library is on include_path set_include_path(implode(PATH_SEPARATOR, array(ZF_PATH, LIBRARY_PATH, get_include_path()))); // Init config require_once 'Zend/Config/Config.php'; require_once 'edp/ModuleLoader.php'; $config = new Zend\Config\Config(include APPLICATION_PATH . '/configs/config.php'); // Init autoloader require_once 'Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory($config->autoload); if (is_array($config->phpSettings)) { foreach ($config->phpSettings as $key => $value) { ini_set($key, $value); } } // Create application, bootstrap, and run $bootstrap = new $config->bootstrap_class($config); $bootstrap->execute();
<?php /** * This autoloading setup is really more complicated than it needs to be for most * applications. The added complexity is simply to reduce the time it takes for * new developers to be productive with a fresh skeleton. It allows autoloading * to be correctly configured, regardless of the installation method and keeps * the use of composer completely optional. This setup should work fine for * most users, however, feel free to configure autoloading however you'd like. */ // Composer autoloading if (file_exists('vendor/autoload.php')) { $loader = (include 'vendor/autoload.php'); } defined('ZF2_PATH') || define('ZF2_PATH', 'vendor/library/'); // Support for ZF2_PATH environment variable or git submodule if ($zf2Path = ZF2_PATH ?: (is_dir('vendor/library') ? 'vendor/library' : false)) { if (isset($loader)) { $loader->add('Zend', $zf2Path . '/Zend'); } else { include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array('My' => __DIR__ . '/vendor/My')))); } } if (!class_exists('Zend\\Loader\\AutoloaderFactory')) { throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); }
<?php require_once "define.php"; include LIB_PATH . '/Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, "namespaces" => array("ZendVN" => LIB_PATH . "ZendVN"), "prefixes" => array("HTMLPurifier" => LIB_PATH . "HTMLPurifier")))); if (!class_exists('Zend\\Loader\\AutoloaderFactory')) { throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); } // Run the application! Zend\Mvc\Application::init(require 'config/application.config.php')->run();
// redirect www to non www if (substr(strtolower($_SERVER['HTTP_HOST']), 0, 4) === 'www.') { $host = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://'; $host .= substr($_SERVER['HTTP_HOST'], 4); if ($_SERVER["SERVER_PORT"] != '80') { $host .= ':' . $_SERVER['SERVER_PORT']; } header('Location: ' . $host . $_SERVER['REQUEST_URI']); exit; } // force https //if(getenv('APPLICATION_ENV') == 'production' && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off')) { // header('Location: http://mentor.funix.edu.vn'. $_SERVER['REQUEST_URI']); // exit; //} defined('DS') || define('DS', DIRECTORY_SEPARATOR); defined('BASE_PATH') || define('BASE_PATH', dirname(dirname(__FILE__))); defined('LIB_PATH') || define('LIB_PATH', getenv("LIB_PATH")); defined('VENDOR_PATH') || define('VENDOR_PATH', realpath(BASE_PATH . '/vendor')); defined('TEMPLATES_PATH') || define('TEMPLATES_PATH', realpath(BASE_PATH . '/public/tp')); defined('MEDIA_PATH') || define('MEDIA_PATH', realpath(BASE_PATH . '/public/media')); set_include_path(implode(PATH_SEPARATOR, array(LIB_PATH, VENDOR_PATH, get_include_path()))); $zendPath = VENDOR_PATH; /** * This makes our life easier when dealing with paths. Everything is relative * to the application root now. */ chdir(dirname(__DIR__)); include 'Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('namespaces' => array('Zend' => VENDOR_PATH . '/Zend', 'ZendX' => VENDOR_PATH . '/ZendX', 'ZendService' => VENDOR_PATH . '/ZendService')))); Zend\Mvc\Application::init(require BASE_PATH . '/config/application.config.php')->run();
<?php /* Simple autoloader for Zend Framework + ZendPdf component Inspired from https://github.com/zendframework/ZendSkeletonApplication Set autoregister_zf for Zend Framework Set fallback_autoloader for dependencies which are PSR-0 compliant */ require_once '/usr/share/php/Zend//Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('fallback_autoloader' => true, 'autoregister_zf' => true, 'namespaces' => array('ZendPdf' => __DIR__))));
<?php spl_autoload_register(include __DIR__ . '/autoload_function.php'); require_once __DIR__ . '/Module.php'; $module = new DoctrineModule\Module(); Zend\Loader\AutoloaderFactory::factory($module->getAutoloaderConfig());
* applications. The added complexity is simply to reduce the time it takes for * new developers to be productive with a fresh skeleton. It allows autoloading * to be correctly configured, regardless of the installation method and keeps * the use of composer completely optional. This setup should work fine for * most users, however, feel free to configure autoloading however you'd like. */ // Composer autoloading if (file_exists('vendor/autoload.php')) { $loader = (include 'vendor/autoload.php'); } $zf2Path = false; if (getenv('ZF2_PATH')) { // Support for ZF2_PATH environment variable or git submodule $zf2Path = getenv('ZF2_PATH'); } elseif (get_cfg_var('zf2_path')) { // Support for zf2_path directive value $zf2Path = get_cfg_var('zf2_path'); } elseif (is_dir('vendor/zf2/library')) { $zf2Path = 'vendor/zf2/library'; } if ($zf2Path) { if (isset($loader)) { $loader->add('Zend', $zf2Path); } else { include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'prefixes' => array('Twig' => __DIR__ . '/vendor/twig/lib/Twig')))); } } if (!class_exists('Zend\\Loader\\AutoloaderFactory')) { throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); }
* applications. The added complexity is simply to reduce the time it takes for * new developers to be productive with a fresh skeleton. It allows autoloading * to be correctly configured, regardless of the installation method and keeps * the use of composer completely optional. This setup should work fine for * most users, however, feel free to configure autoloading however you'd like. */ // Composer autoloading if (file_exists('vendor/autoload.php')) { $loader = (include 'vendor/autoload.php'); } $zf2Path = false; if (is_dir('vendor/ZF2/library')) { $zf2Path = 'vendor/ZF2/library'; } elseif (getenv('ZF2_PATH')) { // Support for ZF2_PATH environment variable or git submodule $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); } else { include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array('Doctrine\\Common' => __DIR__ . '/vendor/doctrine/common', 'Doctrine\\DBAL' => __DIR__ . '/vendor/doctrine/dbal', 'Symfony\\Console' => __DIR__ . '/vendor/symfony/console', 'DoctrineModule' => __DIR__ . '/vendor/doctrine/doctrine-module', 'DoctrineORMModule' => __DIR__ . '/vendor/doctrine/doctrine-orm-module')))); } } if (!class_exists('Zend\\Loader\\AutoloaderFactory')) { throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); }
* applications. The added complexity is simply to reduce the time it takes for * new developers to be productive with a fresh skeleton. It allows autoloading * to be correctly configured, regardless of the installation method and keeps * the use of composer completely optional. This setup should work fine for * most users, however, feel free to configure autoloading however you'd like. */ // Composer autoloading if (file_exists('vendor/autoload.php')) { $loader = (include 'vendor/autoload.php'); } $zf2Path = false; if (is_dir('vendor/ZF2/library')) { $zf2Path = 'vendor/ZF2/library'; } elseif (getenv('ZF2_PATH')) { // Support for ZF2_PATH environment variable or git submodule $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); } else { include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array(__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, 'MyLib' => __DIR__ . '/vendor/MyLib', 'PCurlThread' => __DIR__ . '/vendor/PCurlThread')))); } } if (!class_exists('Zend\\Loader\\AutoloaderFactory')) { throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); }
<?php /** * This makes our life easier when dealing with paths. Everything is relative * to the application root now. */ include 'define.php'; // Decline static file requests back to the PHP built-in webserver if (php_sapi_name() === 'cli-server') { $path = realpath(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)); if (__FILE__ !== $path && is_file($path)) { return false; } unset($path); } // Setup autoloading require 'init_autoloader.php'; /** Options autoloader*/ require 'define.php'; //include LIBRARY_PATH . '/../../../Zend/Loader/AutoloaderFactory.php'; @(include LIBRARY_PATH); Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array('ZendVN' => LIBRARY_PATH . '/../../../ZendVN'), 'prefixes' => array('HTMLPurifier' => LIBRARY_PATH . '/../../../HTMLPurifier')))); // Run the application! Zend\Mvc\Application::init(require 'config/application.config.php')->run(); /** init_autoloader.php */ /** vendor/autoloader.php */
<?php require_once __DIR__ . '/../../zf2/library/Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array('SimplePageCrawler' => __DIR__ . '/../src/SimplePageCrawler', 'SimplePageCrawlerTest' => __DIR__ . '/SimplePageCrawler'))));
/** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ /** * This autoloading setup is really more complicated than it needs to be for most * applications. The added complexity is simply to reduce the time it takes for * new developers to be productive with a fresh skeleton. It allows autoloading * to be correctly configured, regardless of the installation method and keeps * the use of composer completely optional. This setup should work fine for * most users, however, feel free to configure autoloading however you'd like. */ if (APP_ENV === 'production') { require_once 'vendor/zendframework/zendframework/library/Zend/Loader/AutoloaderFactory.php'; require_once 'vendor/zendframework/zendframework/library/Zend/Loader/ClassMapAutoloader.php'; if (!file_exists('vendor/composer/autoload_classmap.php')) { throw new RuntimeException('Unable to load vendor classmap. Run `php composer.phar install -o`.'); } Zend\Loader\AutoloaderFactory::factory(['Zend\\Loader\\ClassMapAutoloader' => ['Composer' => 'vendor/composer/autoload_classmap.php']]); } else { // Composer autoloading if (file_exists('vendor/autoload.php')) { $loader = (include 'vendor/autoload.php'); } } if (!class_exists('Zend\\Loader\\AutoloaderFactory')) { throw new RuntimeException('Unable to load dependencies. Run `php composer.phar install`.'); }
<?php ini_set('display_errors', '1'); error_reporting(-1); // Define application environment defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'); // Ensure ZF is on the include path set_include_path(implode(PATH_SEPARATOR, array(realpath(__DIR__ . '/../library'), realpath(__DIR__ . '/../library/ZendFramework/library'), get_include_path()))); require_once 'Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array())); $appConfig = new Zend\Config\Config(include __DIR__ . '/../configs/application.config.php'); $moduleLoader = new Zend\Loader\ModuleAutoloader($appConfig['module_paths']); $moduleLoader->register(); $moduleManager = new Zend\Module\Manager($appConfig['modules'], new Zend\Module\ManagerOptions($appConfig['module_manager_options'])); // Create application, bootstrap, and run $bootstrap = new Zend\Mvc\Bootstrap($moduleManager); $application = new Zend\Mvc\Application(); $bootstrap->bootstrap($application); $application->run()->send();
* to be correctly configured, regardless of the installation method and keeps * the use of composer completely optional. This setup should work fine for * most users, however, feel free to configure autoloading however you'd like. */ // Composer autoloading if (file_exists('vendor/autoload.php')) { $loader = (include 'vendor/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))); } } if (!class_exists('Zend\\Loader\\AutoloaderFactory')) { throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); }
<?php /** * This makes our life easier when dealing with paths. Everything is relative * to the application root now. */ chdir(dirname(__DIR__)); // Decline static file requests back to the PHP built-in webserver if (php_sapi_name() === 'cli-server' && is_file(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) { return false; } // Setup autoloading require 'init_autoloader.php'; Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('namespaces' => array('Mylib' => dirname(__DIR__) . '/vendor/Mylib/Services/Mylib')))); // Run the application! Zend\Mvc\Application::init(require 'config/application.config.php')->run();
// Path to Zend Framework defined('ZF_PATH') || define('ZF_PATH', realpath(LIBRARY_PATH . '/ZendFramework2/library')); // Application environment defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production')); // Set include path set_include_path(implode(PATH_SEPARATOR, array(ZF_PATH, LIBRARY_PATH, get_include_path()))); // Init config require_once 'Zend/Config/Config.php'; $config = new Zend\Config\Config(include APPLICATION_PATH . '/configs/config.php'); // Init autoloader require_once 'Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory($config->autoload->toArray()); // PHP settings foreach ($config->phpSettings as $key => $value) { ini_set($key, $value); } // Bootstrap $bootstrap = new $config->bootstrap_class($config); $bootstrap->execute();
* new developers to be productive with a fresh skeleton. It allows autoloading * to be correctly configured, regardless of the installation method and keeps * the use of composer completely optional. This setup should work fine for * most users, however, feel free to configure autoloading however you'd like. */ // Composer autoloading if (file_exists('vendor/autoload.php')) { $loader = (include 'vendor/autoload.php'); } if (!class_exists('Zend\\Loader\\AutoloaderFactory')) { exit('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); } // 加载自己的函数库 if (file_exists(__DIR__ . '/library/function.php')) { include __DIR__ . '/library/function.php'; } // 加载自己的函数库 $myAutoLoaderClass = array('My' => __DIR__ . '/library/My'); try { if (is_array($myAutoLoaderClass)) { foreach ($myAutoLoaderClass as $namespace => $libraryPath) { if (is_dir($libraryPath)) { Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('namespaces' => array($namespace => $libraryPath)))); } else { throw new Exception($libraryPath . ' is not a dir'); } } } } catch (Exception $e) { exit(exceptionMsg($e)); }