Update public/index.php
[zf2.biz/application_blanche.git] / public / index.php
1 <?php
2 chdir(dirname(__DIR__));
3 require_once (getenv('ZF2_PATH') ?: 'vendor/ZendFramework/library') . '/Zend/Loader/AutoloaderFactory.php';
4 Zend\Loader\AutoloaderFactory::factory();
5
6 if (!($env = getenv('APPLICATION_ENV'))) {
7     $env = 'local';
8 }
9
10 $appConfig = include 'config/application.config.php';
11
12 $listenerOptions  = new Zend\Module\Listener\ListenerOptions($appConfig['module_listener_options']);
13 $defaultListeners = new Zend\Module\Listener\DefaultListenerAggregate($listenerOptions);
14 $defaultListeners->getConfigListener()->addConfigGlobPath("config/autoload/*.{global,$env}..configphp");
15
16 $moduleManager = new Zend\Module\Manager($appConfig['modules']);
17 $moduleManager->events()->attachAggregate($defaultListeners);
18 $moduleManager->loadModules();
19
20 // Create application, bootstrap, and run
21 $bootstrap   = new Zend\Mvc\Bootstrap($defaultListeners->getConfigListener()->getMergedConfig());
22 $application = new Zend\Mvc\Application;
23 $bootstrap->bootstrap($application);
24 $application->run()->send();