PHP Class Zend\Mvc\Application
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:
$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.
Show file
Open project: zendframework/zend-mvc
Class Usage Examples
Protected Properties
Public Methods
Method |
Description |
|
__construct ( Zend\ServiceManager\ServiceManager $serviceManager, Zend\EventManager\EventManagerInterface $events = null, Zend\Stdlib\RequestInterface $request = null, Zend\Stdlib\ResponseInterface $response = null ) |
Constructor |
|
bootstrap ( array $listeners = [] ) : Application |
Bootstrap the application |
|
getConfig ( ) : array | object |
Retrieve the application configuration |
|
getEventManager ( ) : Zend\EventManager\EventManagerInterface |
Retrieve the event manager |
|
getMvcEvent ( ) : MvcEvent |
Get the MVC event instance |
|
getRequest ( ) : Zend\Stdlib\RequestInterface |
Get the request object |
|
getResponse ( ) : Zend\Stdlib\ResponseInterface |
Get the response object |
|
getServiceManager ( ) : Zend\ServiceManager\ServiceManager |
Retrieve the service manager |
|
init ( array $configuration = [] ) : Application |
Static method for quick and easy initialization of the Application. |
|
run ( ) : self |
Run the application |
|
setEventManager ( Zend\EventManager\EventManagerInterface $eventManager ) : Application |
Set the event manager instance |
|
Protected Methods
Method |
Description |
|
completeRequest ( MvcEvent $event ) : Application |
Complete the request |
|
Method Details
__construct()
public method
public __construct ( Zend\ServiceManager\ServiceManager $serviceManager, Zend\EventManager\EventManagerInterface $events = null, Zend\Stdlib\RequestInterface $request = null, Zend\Stdlib\ResponseInterface $response = null ) |
$serviceManager |
Zend\ServiceManager\ServiceManager |
|
$events |
Zend\EventManager\EventManagerInterface |
|
$request |
Zend\Stdlib\RequestInterface |
|
$response |
Zend\Stdlib\ResponseInterface |
|
bootstrap()
public method
Defines and binds the MvcEvent, and passes it the request, response, and
router. Attaches the ViewManager as a listener. Triggers the bootstrap
event.
public bootstrap ( array $listeners = [] ) : Application |
$listeners |
array |
List of listeners to attach. |
return |
Application |
|
completeRequest()
protected method
Triggers "render" and "finish" events, and returns response from
event object.
protected completeRequest ( MvcEvent $event ) : Application |
$event |
MvcEvent |
|
return |
Application |
|
getConfig()
public method
Retrieve the application configuration
getEventManager()
public method
Lazy-loads an EventManager instance if none registered.
public getEventManager ( ) : Zend\EventManager\EventManagerInterface |
return |
Zend\EventManager\EventManagerInterface |
|
getMvcEvent()
public method
Get the MVC event instance
getRequest()
public method
public getRequest ( ) : Zend\Stdlib\RequestInterface |
return |
Zend\Stdlib\RequestInterface |
|
getResponse()
public method
public getResponse ( ) : Zend\Stdlib\ResponseInterface |
return |
Zend\Stdlib\ResponseInterface |
|
getServiceManager()
public method
Retrieve the service manager
public getServiceManager ( ) : Zend\ServiceManager\ServiceManager |
return |
Zend\ServiceManager\ServiceManager |
|
init()
public static method
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 & Zend\EventManager\EventManagerInterface
All other services are configured after module loading, thus can be
overridden by modules.
public static init ( array $configuration = [] ) : Application |
$configuration |
array |
|
return |
Application |
|
public run ( ) : self |
return |
self |
|
setEventManager()
public method
Set the event manager instance
public setEventManager ( Zend\EventManager\EventManagerInterface $eventManager ) : Application |
$eventManager |
Zend\EventManager\EventManagerInterface |
|
return |
Application |
|
Property Details
$defaultListeners protected property
Default application event listeners
protected array $defaultListeners |
return |
array |
|
$event protected property
protected MvcEvent,Zend\Mvc $event |
return |
MvcEvent |
|
$events protected property
protected EventManagerInterface,Zend\EventManager $events |
return |
Zend\EventManager\EventManagerInterface |
|
$request protected property
protected RequestInterface,Zend\Stdlib $request |
return |
Zend\Stdlib\RequestInterface |
|
$response protected property
protected ResponseInterface,Zend\Stdlib $response |
return |
Zend\Stdlib\ResponseInterface |
|
$serviceManager protected property
protected ServiceManager,Zend\ServiceManager $serviceManager |
return |
Zend\ServiceManager\ServiceManager |
|