Class Application

Summary

Fully Qualified Name: Zend\Mvc\Application
Implements: ApplicationInterface, EventManagerAwareInterface

Description

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.

Methods

Name Description Defined By
__construct() Constructor Application
bootstrap() Bootstrap the application Application
getConfig() Retrieve the application configuration Application
getEventManager() Retrieve the event manager Application
getMvcEvent() Get the MVC event instance Application
getRequest() Get the request object Application
getResponse() Get the response object Application
getServiceManager() Retrieve the service manager Application
init() Static method for quick and easy initialization of the Application. Application
run() Run the application Application
setEventManager() Set the event manager instance Application

Method Details

__construct()

Constructor

Parameter Name Type Description
$serviceManager \ServiceManager
$events null|\EventManagerInterface
$request null|\RequestInterface
$response null|\ResponseInterface

Returns:

bootstrap()

Bootstrap the application

Defines and binds the MvcEvent, and passes it the request, response, and router. Attaches the ViewManager as a listener. Triggers the bootstrap event.

Parameter Name Type Description
$listeners array List

Returns: \Application

getConfig()

Retrieve the application configuration

Returns: array|object

getEventManager()

Retrieve the event manager

Lazy-loads an EventManager instance if none registered.

Returns: \EventManagerInterface

getMvcEvent()

Get the MVC event instance

Returns: \MvcEvent

getRequest()

Get the request object

Returns: \Zend\Stdlib\RequestInterface

getResponse()

Get the response object

Returns: \ResponseInterface

getServiceManager()

Retrieve the service manager

Returns: \ServiceManager

init()

Static method for quick and easy initialization of the 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.

Parameter Name Type Description
$configuration array

Returns: \Application

run()

Run the application

Returns: self

setEventManager()

Set the event manager instance

Parameter Name Type Description
$eventManager \EventManagerInterface

Returns: \Application

Top