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 Zend\ServiceManager\ServiceManager($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.
Synopsis
class Application
implements
ApplicationInterface,EventManagerAwareInterface
{
- // constants
- const ERROR_CONTROLLER_CANNOT_DISPATCH = 'error-controller-cannot-dispatch';
- const ERROR_CONTROLLER_NOT_FOUND = 'error-controller-not-found';
- const ERROR_CONTROLLER_INVALID = 'error-controller-invalid';
- const ERROR_EXCEPTION = 'error-exception';
- const ERROR_ROUTER_NO_MATCH = 'error-router-no-match';
- // members
- protected array $configuration;
- protected array $defaultListeners;
- protected MvcEvent $event;
- protected EventManagerInterface $events;
- protected RequestInterface $request;
- protected ResponseInterface $response;
- protected ServiceManager $serviceManager;
- // methods
- public void __construct()
- public array|object getConfig()
- public Application bootstrap()
- public ServiceManager getServiceManager()
- public RequestInterface getRequest()
- public ResponseInterface getResponse()
- public MvcEvent getMvcEvent()
- public Application setEventManager()
- public EventManagerInterface getEventManager()
- public static Application init()
- public self run()
- public void send()
- protected Application completeRequest()
Hierarchy
Constants
Name | Value |
---|---|
ERROR_CONTROLLER_CANNOT_DISPATCH | 'error-controller-cannot-dispatch' |
ERROR_CONTROLLER_NOT_FOUND | 'error-controller-not-found' |
ERROR_CONTROLLER_INVALID | 'error-controller-invalid' |
ERROR_EXCEPTION | 'error-exception' |
ERROR_ROUTER_NO_MATCH | 'error-router-no-match' |
Members
protected
- $configuration — array
- $defaultListeners
—
array
Default application event listeners - $event
—
Zend\Mvc\MvcEvent
MVC event token - $events — Zend\EventManager\EventManagerInterface
- $request — \Zend\Stdlib\RequestInterface
- $response — Zend\Stdlib\ResponseInterface
- $serviceManager — Zend\ServiceManager\ServiceManager
Methods
protected
- completeRequest() — Complete the request
public
- __construct() — Constructor
- bootstrap() — Bootstrap the application
- getConfig() — Retrieve the application configuration
- getEventManager() — Retrieve the event manager
- getMvcEvent() — Get the MVC event instance
- getRequest() — Get the request object
- getResponse() — Get the response object
- getServiceManager() — Retrieve the service manager
- init() — Static method for quick and easy initialization of the Application.
- run() — Run the application
- send()
- setEventManager() — Set the event manager instance