__construct()
bootstrap()
getConfig()
getEventManager()
getMvcEvent()
getRequest()
getResponse()
getServiceManager()
init()
run()
send()
setEventManager()
completeRequest()
$configuration
$defaultListeners
$event
$events
$request
$response
$serviceManager
ERROR_CONTROLLER_CANNOT_DISPATCH
ERROR_CONTROLLER_INVALID
ERROR_CONTROLLER_NOT_FOUND
ERROR_EXCEPTION
ERROR_ROUTER_NO_MATCH
Main application class for invoking applications
Expects the user will provide a configured ServiceManager, configured with the following services:
The most common workflow is:
$services = new Zend\ServiceManager\ServiceManager($servicesConfig);
$app = new Application($appConfig, $services);
$app->bootstrap();
$response = $app->run();
$response->send();
bootstrap() opts in to the default route, dispatch, and view listeners, sets up the MvcEvent, and triggers the bootstrap event. This can be omitted if you wish to setup your own listeners and/or workflow; alternately, you can simply extend the class to override such behavior.
__construct(mixed $configuration, \Zend\ServiceManager\ServiceManager $serviceManager)
bootstrap(array $listeners) : \Zend\Mvc\Application
Defines and binds the MvcEvent, and passes it the request, response, and router. Attaches the ViewManager as a listener. Triggers the bootstrap event.
array
List of listeners to attach.
getConfig() : array | object
array
object
getEventManager() : \Zend\EventManager\EventManagerInterface
Lazy-loads an EventManager instance if none registered.
getServiceManager() : \Zend\ServiceManager\ServiceManager
init(array $configuration) : \Zend\Mvc\Application
If you use this init() method, you cannot specify a service with the name of 'ApplicationConfig' in your service manager config. This name is reserved to hold the array from application.config.php.
The following services can only be overridden from application.config.php:
All other services are configured after module loading, thus can be overridden by modules.
array
run() : \Zend\Mvc\self
triggers | route(MvcEvent) Routes the request, and sets the RouteMatch object in the event. |
---|---|
triggers | dispatch(MvcEvent) Dispatches a request, using the discovered RouteMatch and provided request. |
triggers | dispatch.error(MvcEvent) On errors (controller not found, action not supported, etc.), populates the event with information about the error type, discovered controller, and controller class (if known). Typically, a handler should return a populated Response object that can be returned immediately. |
\Zend\Mvc\self
send()
deprecated |
---|
setEventManager(\Zend\EventManager\EventManagerInterface $eventManager) : \Zend\Mvc\Application
completeRequest(\Zend\Mvc\MvcEvent $event) : \Zend\Mvc\Application
Triggers "render" and "finish" events, and returns response from event object.
\Zend\Mvc\MvcEvent
$configuration : array
$defaultListeners : array
ERROR_CONTROLLER_CANNOT_DISPATCH
ERROR_CONTROLLER_INVALID
ERROR_CONTROLLER_NOT_FOUND
ERROR_EXCEPTION
ERROR_ROUTER_NO_MATCH