Fully Qualified Name: | Laminas\Mvc\Application |
Implements: | ApplicationInterface, EventManagerAwareInterface |
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 Laminas\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.
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 |
Constructor
Parameter Name | Type | Description |
---|---|---|
$serviceManager | \ServiceManager | |
$events | null|\EventManagerInterface | |
$request | null|\RequestInterface | |
$response | null|\ResponseInterface |
Returns:
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
Retrieve the application configuration
Returns: array|object
Retrieve the event manager
Lazy-loads an EventManager instance if none registered.
Returns: \EventManagerInterface
Get the MVC event instance
Returns: \MvcEvent
Get the request object
Returns: \Laminas\Stdlib\RequestInterface
Get the response object
Returns: \ResponseInterface
Retrieve the service manager
Returns: \ServiceManager
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 the application
Returns: self
Set the event manager instance
Parameter Name | Type | Description |
---|---|---|
$eventManager | \EventManagerInterface |
Returns: \Application