1217. Class

1217.1. Zend\Mvc\Application

Main application class for invoking applications

Expects the user will provide a configured ServiceManager, configured with the following services:

  • EventManager
  • ModuleManager
  • Request
  • Response
  • RouteListener
  • Router
  • DispatchListener
  • ViewManager

The most common workflow is: <code> $services = new ZendServiceManagerServiceManager($servicesConfig); $app = new Application($appConfig, $services); $app->bootstrap(); $response = $app->run(); $response->send(); </code>

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.

1217.1.1. Methods

1217.1.1.1. __construct

__construct()

Constructor

Parameters:
  • mixed
  • ServiceManager

1217.1.1.2. getConfig

getConfig()

Retrieve the application configuration

Return type:array|object

1217.1.1.3. bootstrap

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.

Return type:Application

1217.1.1.4. getServiceManager

getServiceManager()

Retrieve the service manager

Return type:ServiceManager

1217.1.1.5. getRequest

getRequest()

Get the request object

Return type:ZendStdlibRequestInterface

1217.1.1.6. getResponse

getResponse()

Get the response object

Return type:ResponseInterface

1217.1.1.7. getMvcEvent

getMvcEvent()

Get the MVC event instance

Return type:MvcEvent

1217.1.1.8. setEventManager

setEventManager()

Set the event manager instance

Parameters:EventManagerInterface
Return type:Application

1217.1.1.9. getEventManager

getEventManager()

Retrieve the event manager

Lazy-loads an EventManager instance if none registered.

Return type:EventManagerInterface

1217.1.1.10. init

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:

  • ModuleManager
  • SharedEventManager
  • EventManager & ZendEventManagerEventManagerInterface

All other services are configured after module loading, thus can be overridden by modules.

Parameters:array
Return type:Application

1217.1.1.11. run

run()

Run the application

Return type:ResponseInterface

1217.1.1.12. send

send()

@deprecated

1217.1.1.13. completeRequest

completeRequest()

Complete the request

Triggers “render” and “finish” events, and returns response from event object.

Parameters:MvcEvent
Return type:ResponseInterface

1217.1.2. Constants

1217.1.2.1. ERROR_CONTROLLER_CANNOT_DISPATCH

1217.1.2.2. ERROR_CONTROLLER_NOT_FOUND

1217.1.2.3. ERROR_CONTROLLER_INVALID

1217.1.2.4. ERROR_EXCEPTION

1217.1.2.5. ERROR_ROUTER_NO_MATCH