5d7a3d7b6510c3754ba63185587ee128861a9e08
[zf2.biz/galerie.git] / public / index.php
1 <?php
2 use Zend\Loader\AutoloaderFactory;
3 use Zend\ServiceManager\ServiceManager;
4 use Zend\Mvc\Service\ServiceManagerConfiguration;
5
6 chdir(dirname(__DIR__));
7
8 // Composer autoloading
9 if (file_exists('vendor/autoload.php')) {
10     $loader = include 'vendor/autoload.php';
11 }
12
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)) {
15     if (isset($loader)) {
16         $loader->add('Zend', $zf2Path . '/Zend');
17     } else {
18         include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
19         AutoloaderFactory::factory();
20     }
21 }
22
23 if (!class_exists('Zend\Loader\AutoloaderFactory')) {
24     throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.');
25 }
26
27 // Get application stack configuration
28 $configuration = include 'config/application.config.php';
29
30 // Setup service manager
31 $serviceManager = new ServiceManager(new ServiceManagerConfiguration($configuration['service_manager']));
32 $serviceManager->setService('ApplicationConfiguration', $configuration);
33 $serviceManager->get('ModuleManager')->loadModules();
34
35 // Run application
36 $serviceManager->get('Application')->bootstrap()->run()->send();