2 use Zend\Loader\AutoloaderFactory;
3 use Zend\ServiceManager\ServiceManager;
4 use Zend\Mvc\Service\ServiceManagerConfiguration;
6 chdir(dirname(__DIR__));
8 // Composer autoloading
9 if (file_exists('vendor/autoload.php')) {
10 $loader = include 'vendor/autoload.php';
13 // Support for ZF2_PATH environment variable or git submodule
14 if ($zf2Path = getenv('ZF2_PATH') ?: (is_dir('vendor/ZF2/library') ? 'vendor/ZF2/library' : false)) {
16 $loader->add('Zend', $zf2Path . '/Zend');
18 include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
19 AutoloaderFactory::factory(array(
20 'Zend\Loader\StandardAutoloader' => array(
21 'autoregister_zf' => true
27 if (!class_exists('Zend\Loader\AutoloaderFactory')) {
28 throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.');
31 // Get application stack configuration
32 $configuration = include 'config/application.config.php';
34 // Setup service manager
35 $serviceManager = new ServiceManager(new ServiceManagerConfiguration($configuration['service_manager']));
36 $serviceManager->setService('ApplicationConfiguration', $configuration);
37 $serviceManager->get('ModuleManager')->loadModules();
40 $serviceManager->get('Application')->bootstrap()->run()->send();