Final Class Yiisoft\Yii\Http\Application
| Inheritance | Yiisoft\ |
|---|
Application is the entry point for an HTTP application.
For more details and usage information on Application, see the guide article on applications:
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| afterEmit() | Dispatches an event {@see AfterEmit} to all relevant listeners for processing. | Yiisoft\ |
| handle() | Handles a request by passing it through the middleware stack {@see MiddlewareDispatcher} and returns a response. | Yiisoft\ |
| shutdown() | Dispatches an event {@see ApplicationShutdown} to all relevant listeners for processing. | Yiisoft\ |
| start() | Dispatches an event {@see ApplicationStartup} to all relevant listeners for processing. | Yiisoft\ |
Method Details
| public mixed __construct ( \ | ||
| $dispatcher | \ |
The middleware dispatcher instance. |
| $eventDispatcher | \ |
The event dispatcher instance (optional). |
| $fallbackHandler | \ |
The fallback handler that will be called if no response was returned during request handling. |
public function __construct(
private readonly MiddlewareDispatcher $dispatcher,
private readonly ?EventDispatcherInterface $eventDispatcher = null,
private readonly RequestHandlerInterface $fallbackHandler = new UnhandledRequestHandler(),
) {}
Dispatches an event {@see AfterEmit} to all relevant listeners for processing.
| public void afterEmit ( \ | ||
| $response | \ |
Response instance or null if response generation failed due to an error. |
public function afterEmit(?ResponseInterface $response): void
{
$this->eventDispatcher?->dispatch(new AfterEmit($response));
}
Handles a request by passing it through the middleware stack {@see MiddlewareDispatcher} and returns a response.
Dispatches {@see \
| public \ | ||
| $request | \ |
The request instance to handle. |
| return | \ |
The resulting instance of the response. |
|---|---|---|
public function handle(ServerRequestInterface $request): ResponseInterface
{
$this->eventDispatcher?->dispatch(new BeforeRequest($request));
try {
return $response = $this->dispatcher->dispatch($request, $this->fallbackHandler);
} finally {
$this->eventDispatcher?->dispatch(new AfterRequest($response ?? null));
}
}
Dispatches an event {@see ApplicationShutdown} to all relevant listeners for processing.
| public void shutdown ( ) |
public function shutdown(): void
{
$this->eventDispatcher?->dispatch(new ApplicationShutdown());
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.