AppInit
in package
implements
RequestHandlerInterface
Interfaces, Classes, Traits and Enums
- RequestHandlerInterface
Table of Contents
- $defaultHandler : null|callable
- $errorHandler : null|callable
- $exception : null|Throwable
- $middlewareRegistry : MiddlewareRegistry
- __construct() : mixed
- AppInit constructor.
- handle() : ResponseInterface
- The PSR-15 compliant method to handle a request.
- run() : void
- Start the application by handling the given request.
- setDefaultHandler() : static
- Set the default handler that processes the final request if no other middleware modifies it.
- setErrorHandler() : static
- Set the error handler middleware.
- withMiddleware() : static
- Add middleware to the application via MiddlewareRegistry.
- emitResponse() : void
- handleException() : ResponseInterface
- Method to handle exceptions using the defined error handler.
Properties
$defaultHandler
protected
null|callable
$defaultHandler
$errorHandler
protected
null|callable
$errorHandler
$exception
protected
null|Throwable
$exception
$middlewareRegistry
protected
MiddlewareRegistry
$middlewareRegistry
Methods
__construct()
AppInit constructor.
public
__construct() : mixed
Return values
mixed —handle()
The PSR-15 compliant method to handle a request.
public
handle(RequestInterface $request) : ResponseInterface
Parameters
- $request : RequestInterface
Return values
ResponseInterface —run()
Start the application by handling the given request.
public
run(RequestInterface $request) : void
Parameters
- $request : RequestInterface
Return values
void —setDefaultHandler()
Set the default handler that processes the final request if no other middleware modifies it.
public
setDefaultHandler(callable $defaultHandler) : static
Parameters
- $defaultHandler : callable
Return values
static —setErrorHandler()
Set the error handler middleware.
public
setErrorHandler(callable $errorHandler) : static
Parameters
- $errorHandler : callable
Return values
static —withMiddleware()
Add middleware to the application via MiddlewareRegistry.
public
withMiddleware(callable|MiddlewareInterface $middleware[, string $key = '' ]) : static
Parameters
- $middleware : callable|MiddlewareInterface
- $key : string = ''
Return values
static —emitResponse()
protected
emitResponse(ResponseInterface $response) : void
Parameters
- $response : ResponseInterface
Return values
void —handleException()
Method to handle exceptions using the defined error handler.
protected
handleException(Throwable $except, RequestInterface $request) : ResponseInterface
Parameters
- $except : Throwable
- $request : RequestInterface