[submodule "vendor/ZendFramework"]
path = vendor/ZendFramework
- url = git://github.com/zendframework/zf2.git
+ url = git://github.com/weierophinney/zf2.git
'./vendor',
),
),
+ 'service_manager' => array(
+ 'use_defaults' => true,
+ 'factories' => array(
+ ),
+ ),
);
=====================
By default, this application is configured to load all configs in
-`./config/autoload/{,*.}{global,local}.config.php`. Doing this provides a
+`./config/autoload/{,*.}{global,local}.php`. Doing this provides a
location for a developer to drop in configuration override files provided by
modules, as well as cleanly provide individual, application-wide config files
for things like database connections, etc.
+++ /dev/null
-<?php
-/**
- * Global Configuration Override
- *
- * You can use this file for overridding configuration values from modules, etc.
- * You would place values in here that are agnostic to the environment and not
- * sensitive to security.
- *
- * @NOTE: In practice, this file will typically be INCLUDED in your source
- * control, so do not include passwords or other sensitive information in this
- * file.
- */
-
-return array(
- // ...
-);
--- /dev/null
+<?php
+/**
+ * Global Configuration Override
+ *
+ * You can use this file for overridding configuration values from modules, etc.
+ * You would place values in here that are agnostic to the environment and not
+ * sensitive to security.
+ *
+ * @NOTE: In practice, this file will typically be INCLUDED in your source
+ * control, so do not include passwords or other sensitive information in this
+ * file.
+ */
+
+return array(
+ // ...
+);
+++ /dev/null
-<?php
-/**
- * Local Configuration Override
- *
- * This configuration override file is for overriding environment-specific and
- * security-sensitive configuration information. Copy this file without the
- * .dist extension at the end and populate values as needed.
- *
- * @NOTE: This file is ignored from Git by default with the .gitignore included
- * in ZendSkeletonApplication. This is a good practice, as it prevents sensitive
- * credentials from accidentally being comitted into version control.
- */
-
-return array(
- // ...
-);
--- /dev/null
+<?php
+/**
+ * Local Configuration Override
+ *
+ * This configuration override file is for overriding environment-specific and
+ * security-sensitive configuration information. Copy this file without the
+ * .dist extension at the end and populate values as needed.
+ *
+ * @NOTE: This file is ignored from Git by default with the .gitignore included
+ * in ZendSkeletonApplication. This is a good practice, as it prevents sensitive
+ * credentials from accidentally being comitted into version control.
+ */
+
+return array(
+ // ...
+);
namespace Application;
-use Zend\Module\Manager,
- Zend\EventManager\StaticEventManager,
- Zend\Module\Consumer\AutoloaderProvider;
-
-class Module implements AutoloaderProvider
+class Module
{
- public function init(Manager $moduleManager)
- {
- $events = $moduleManager->events();
- $sharedEvents = $events->getSharedManager();
- $sharedEvents->attach('bootstrap', 'bootstrap', array($this, 'initializeView'), 100);
- }
-
public function getAutoloaderConfig()
{
return array(
{
return include __DIR__ . '/config/module.config.php';
}
-
- public function initializeView($e)
- {
- $app = $e->getParam('application');
- $basePath = $app->getRequest()->getBasePath();
- $locator = $app->getLocator();
- $renderer = $locator->get('Zend\View\Renderer\PhpRenderer');
- $renderer->plugin('basePath')->setBasePath($basePath);
- }
}
<?php
return array(
- 'di' => array(
- 'instance' => array(
-
- // Setup for controllers.
-
- // Injecting the plugin broker for controller plugins into
- // the action controller for use by all controllers that
- // extend it
- 'Zend\Mvc\Controller\ActionController' => array(
- 'parameters' => array(
- 'broker' => 'Zend\Mvc\Controller\PluginBroker',
- ),
- ),
- 'Zend\Mvc\Controller\PluginBroker' => array(
- 'parameters' => array(
- 'loader' => 'Zend\Mvc\Controller\PluginLoader',
- ),
- ),
-
- // Setup for router and routes
- 'Zend\Mvc\Router\RouteStackInterface' => array(
- 'parameters' => array(
- 'routes' => array(
- 'default' => array(
- 'type' => 'Zend\Mvc\Router\Http\Segment',
- 'options' => array(
- 'route' => '/[:controller[/:action]]',
- 'constraints' => array(
- 'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
- 'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
- ),
- 'defaults' => array(
- 'controller' => 'Application\Controller\IndexController',
- 'action' => 'index',
- ),
- ),
- ),
- 'home' => array(
- 'type' => 'Zend\Mvc\Router\Http\Literal',
- 'options' => array(
- 'route' => '/',
- 'defaults' => array(
- 'controller' => 'Application\Controller\IndexController',
- 'action' => 'index',
- ),
- ),
- ),
+ 'router' => array(
+ 'routes' => array(
+ 'default' => array(
+ 'type' => 'Zend\Mvc\Router\Http\Segment',
+ 'options' => array(
+ 'route' => '/[:controller[/:action]]',
+ 'constraints' => array(
+ 'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
+ 'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
- ),
- ),
-
- // Setup for the view layer.
-
- // Using the PhpRenderer, which just handles html produced by php
- // scripts
- 'Zend\View\Renderer\PhpRenderer' => array(
- 'parameters' => array(
- 'resolver' => 'Zend\View\Resolver\AggregateResolver',
- ),
- ),
- // Defining how the view scripts should be resolved by stacking up
- // a Zend\View\Resolver\TemplateMapResolver and a
- // Zend\View\Resolver\TemplatePathStack
- 'Zend\View\Resolver\AggregateResolver' => array(
- 'injections' => array(
- 'Zend\View\Resolver\TemplateMapResolver',
- 'Zend\View\Resolver\TemplatePathStack',
- ),
- ),
- // Defining where the layout/layout view should be located
- 'Zend\View\Resolver\TemplateMapResolver' => array(
- 'parameters' => array(
- 'map' => array(
- 'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
+ 'defaults' => array(
+ 'controller' => 'IndexController',
+ 'action' => 'index',
),
),
),
- // Defining where to look for views. This works with multiple paths,
- // very similar to include_path
- 'Zend\View\Resolver\TemplatePathStack' => array(
- 'parameters' => array(
- 'paths' => array(
- 'application' => __DIR__ . '/../view',
+ 'home' => array(
+ 'type' => 'Zend\Mvc\Router\Http\Literal',
+ 'options' => array(
+ 'route' => '/',
+ 'defaults' => array(
+ 'controller' => 'IndexController',
+ 'action' => 'index',
),
),
),
- // View for the layout
- 'Zend\Mvc\View\DefaultRenderingStrategy' => array(
- 'parameters' => array(
- 'layoutTemplate' => 'layout/layout',
- ),
- ),
- // Injecting the router into the url helper
- 'Zend\View\Helper\Url' => array(
- 'parameters' => array(
- 'router' => 'Zend\Mvc\Router\RouteStackInterface',
- ),
- ),
- // Configuration for the doctype helper
- 'Zend\View\Helper\Doctype' => array(
- 'parameters' => array(
- 'doctype' => 'HTML5',
- ),
- ),
- // View script rendered in case of 404 exception
- 'Zend\Mvc\View\RouteNotFoundStrategy' => array(
- 'parameters' => array(
- 'displayNotFoundReason' => true,
- 'displayExceptions' => true,
- 'notFoundTemplate' => 'error/404',
- ),
- ),
- // View script rendered in case of other exceptions
- 'Zend\Mvc\View\ExceptionStrategy' => array(
- 'parameters' => array(
- 'displayExceptions' => true,
- 'exceptionTemplate' => 'error/index',
- ),
- ),
+ ),
+ ),
+ 'controller' => array(
+ 'classes' => array(
+ 'IndexController' => 'Application\Controller\IndexController'
+ ),
+ ),
+ 'view_manager' => array(
+ 'display_not_found_reason' => true,
+ 'display_exceptions' => true,
+ 'doctype' => 'HTML5',
+ 'not_found_template' => 'error/404',
+ 'exception_template' => 'error/index',
+ 'template_map' => array(
+ 'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
+ 'index/index' => __DIR__ . '/../view/index/index.phtml',
+ 'error/404' => __DIR__ . '/../view/error/404.phtml',
+ 'error/index' => __DIR__ . '/../view/error/index.phtml',
+ ),
+ 'template_path_stack' => array(
+ 'application' => __DIR__ . '/../view',
),
),
);
<?php
chdir(dirname(__DIR__));
require_once (getenv('ZF2_PATH') ?: 'vendor/ZendFramework/library') . '/Zend/Loader/AutoloaderFactory.php';
-Zend\Loader\AutoloaderFactory::factory();
-$appConfig = include 'config/application.config.php';
+use Zend\Loader\AutoloaderFactory,
+Zend\ServiceManager\ServiceManager,
+Zend\Mvc\Service\ServiceManagerConfiguration;
-$sharedEvents = new Zend\EventManager\SharedEventManager();
-$listenerOptions = new Zend\Module\Listener\ListenerOptions($appConfig['module_listener_options']);
-$defaultListeners = new Zend\Module\Listener\DefaultListenerAggregate($listenerOptions);
-$defaultListeners->getConfigListener()->addConfigGlobPath("config/autoload/*.php");
-
+// setup autoloader
+AutoloaderFactory::factory();
-$moduleManager = new Zend\Module\Manager($appConfig['modules']);
-$events = $moduleManager->events();
-$events->setSharedManager($sharedEvents);
-$events->attach($defaultListeners);
-$moduleManager->loadModules();
+// get application stack configuration
+$configuration = include 'config/application.config.php';
-// Create application, bootstrap, and run
-$bootstrap = new Zend\Mvc\Bootstrap($defaultListeners->getConfigListener()->getMergedConfig());
-$bootstrap->events()->setSharedManager($sharedEvents);
-$application = new Zend\Mvc\Application;
-$bootstrap->bootstrap($application);
-$application->run()->send();
+// 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();
-Subproject commit 448f2bfaad4bfde6200401efda29250a5d6a6af6
+Subproject commit 8eb84d3957d69346bccd876a5dc0f4e2dbb91e9c