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.
Afficher le fichier
Open project: zendframework/zend-mvc
Class Usage Examples
Protected Properties
Méthodes publiques
Méthode |
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 |
|
Méthodes protégées
Méthode |
Description |
|
completeRequest ( MvcEvent $event ) : Application |
Complete the request |
|
Method Details
__construct()
public méthode
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 méthode
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. |
Résultat |
Application |
|
completeRequest()
protected méthode
Triggers "render" and "finish" events, and returns response from
event object.
protected completeRequest ( MvcEvent $event ) : Application |
$event |
MvcEvent |
|
Résultat |
Application |
|
getConfig()
public méthode
Retrieve the application configuration
getEventManager()
public méthode
Lazy-loads an EventManager instance if none registered.
public getEventManager ( ) : Zend\EventManager\EventManagerInterface |
Résultat |
Zend\EventManager\EventManagerInterface |
|
getMvcEvent()
public méthode
Get the MVC event instance
getRequest()
public méthode
public getRequest ( ) : Zend\Stdlib\RequestInterface |
Résultat |
Zend\Stdlib\RequestInterface |
|
getResponse()
public méthode
public getResponse ( ) : Zend\Stdlib\ResponseInterface |
Résultat |
Zend\Stdlib\ResponseInterface |
|
getServiceManager()
public méthode
Retrieve the service manager
public getServiceManager ( ) : Zend\ServiceManager\ServiceManager |
Résultat |
Zend\ServiceManager\ServiceManager |
|
init()
public static méthode
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 |
|
Résultat |
Application |
|
public run ( ) : self |
Résultat |
self |
|
setEventManager()
public méthode
Set the event manager instance
public setEventManager ( Zend\EventManager\EventManagerInterface $eventManager ) : Application |
$eventManager |
Zend\EventManager\EventManagerInterface |
|
Résultat |
Application |
|
Property Details
$defaultListeners protected_oe property
Default application event listeners
protected array $defaultListeners |
Résultat |
array |
|
$event protected_oe property
protected MvcEvent,Zend\Mvc $event |
Résultat |
MvcEvent |
|
$events protected_oe property
protected EventManagerInterface,Zend\EventManager $events |
Résultat |
Zend\EventManager\EventManagerInterface |
|
$request protected_oe property
protected RequestInterface,Zend\Stdlib $request |
Résultat |
Zend\Stdlib\RequestInterface |
|
$response protected_oe property
protected ResponseInterface,Zend\Stdlib $response |
Résultat |
Zend\Stdlib\ResponseInterface |
|
$serviceManager protected_oe property
protected ServiceManager,Zend\ServiceManager $serviceManager |
Résultat |
Zend\ServiceManager\ServiceManager |
|