From 4261f12838b8ac6140ecd483e873b3a79a4d1b91 Mon Sep 17 00:00:00 2001 From: Evan Coury Date: Tue, 3 Jul 2012 15:12:38 -0700 Subject: [PATCH] Clean up index.php significantly --- init_autoloader.php | 33 +++++++++++++++++++++++++++++++++ public/index.php | 44 ++++++++------------------------------------ 2 files changed, 41 insertions(+), 36 deletions(-) create mode 100644 init_autoloader.php diff --git a/init_autoloader.php b/init_autoloader.php new file mode 100644 index 0000000..c9beed6 --- /dev/null +++ b/init_autoloader.php @@ -0,0 +1,33 @@ +add('Zend', $zf2Path . '/Zend'); + } 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.'); +} diff --git a/public/index.php b/public/index.php index f347d34..a39cf1e 100644 --- a/public/index.php +++ b/public/index.php @@ -1,40 +1,12 @@ add('Zend', $zf2Path . '/Zend'); - } else { - include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; - 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.'); -} - -// 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(); +// Setup autoloading +include 'init_autoloader.php'; -// Run application -$serviceManager->get('Application')->bootstrap()->run()->send(); +// Run the application! +Zend\Mvc\Application::init(include 'config/application.config.php')->run()->send(); -- 1.7.10.4