Added README back to vendor/
[zf2.biz/galerie.git] / public / index.php
index 767893c..34c609d 100644 (file)
@@ -1,20 +1,24 @@
 <?php
-require_once dirname(__DIR__) . '/vendor/ZendFramework/library/Zend/Loader/AutoloaderFactory.php';
-Zend\Loader\AutoloaderFactory::factory(array('Zend\Loader\StandardAutoloader' => array()));
+use Zend\ServiceManager\ServiceManager,
+    Zend\Mvc\Service\ServiceManagerConfiguration;
 
-$appConfig = include dirname(__DIR__) . '/config/application.config.php';
+chdir(dirname(__DIR__));
 
-$moduleLoader = new Zend\Loader\ModuleAutoloader($appConfig['module_paths']);
-$moduleLoader->register();
+if (!file_exists('vendor/autoload.php')) {
+    throw new RuntimeException('vendor/autoload.php could not be found. Did you run php composer.phar install?');
+    exit;
+}
 
-$moduleManager = new Zend\Module\Manager($appConfig['modules']);
-$listenerOptions = new Zend\Module\Listener\ListenerOptions($appConfig['module_listener_options']);
-$moduleManager->setDefaultListenerOptions($listenerOptions);
-$moduleManager->getConfigListener()->addConfigGlobPath(dirname(__DIR__) . '/config/autoload/*.config.php');
-$moduleManager->loadModules();
+// Composer autoloading
+require_once('vendor/autoload.php');
 
-// Create application, bootstrap, and run
-$bootstrap   = new Zend\Mvc\Bootstrap($moduleManager->getMergedConfig());
-$application = new Zend\Mvc\Application;
-$bootstrap->bootstrap($application);
-$application->run()->send();
+// Get application stack configuration.
+$configuration = include 'config/application.config.php';
+
+// Setup service manager.
+$serviceManager = new ServiceManager(new ServiceManagerConfiguration($configuration['service_manager']));
+$serviceManager->setService('ApplicationConfiguration', $configuration);
+$serviceManager->get('ModuleManager')->loadModules();
+
+// Run application.
+$serviceManager->get('Application')->bootstrap()->run()->send();