Download the PHP package zfegg/callable-handler-decorator without Composer
On this page you can find all versions of the php package zfegg/callable-handler-decorator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zfegg/callable-handler-decorator
More information about zfegg/callable-handler-decorator
Files in zfegg/callable-handler-decorator
Package callable-handler-decorator
Short Description Using MVC for PSR applications, like dotnet core MVC.
License MIT
Informations about the package callable-handler-decorator
English | 简体中文
PSR MVC handler
Using MVC style for PSR handler applications, like dotnet core MVC.
Using the PHP attributes (annotations), convert the controller to PSR15 RequestHandlerInterface
object.
Installation
Usage
Attributes usage like dotnet core MVC
MVC Route
Getting started with Mezzio
Attributes
Route(string $path, array $middlewares = [], ?string $name = null, array $options = [], ?array $methods = null)
HttpGet(string $path, array $middlewares = [], ?string $name = null, array $options = [])
HttpPost(string $path, array $middlewares = [], ?string $name = null, array $options = [])
HttpPatch(string $path, array $middlewares = [], ?string $name = null, array $options = [])
HttpPut(string $path, array $middlewares = [], ?string $name = null, array $options = [])
HttpDelete(string $path, array $middlewares = [], ?string $name = null, array $options = [])
HttpHead(string $path, array $middlewares = [], ?string $name = null, array $options = [])
Register routes by PHP attributes.
The following code applies #[Route("/[controller]/[action]")]
to the controller:
Combining attribute routes
Wrap controller handler
Using param attributes
FromAttribute(?string $name = null)
$name
default is the parameter name
FromBody(?string $name = null, ?bool $root = false, array $serializerContext = [])
$name
default is the parameter name
FromContainer(?string $name = null)
$name
default is the parameter type
FromCookie(?string $name = null)
$name
default is the parameter name
FromHeader(?string $name = null)
$name
default is the parameter name
FromQuery(?string $name = null)
$name
default is the parameter name
FromServer(string $name)
Default param bindings
Prepare result to PSR response.
Resolves various types of method results convert to 'Psr\Http\Message\ResponseInterface'. For resolve callback result to ResponseInterface.
Zfegg\PsrMvc\Preparer\SerializationPreparer
Zfegg\PsrMvc\Preparer\SerializationPreparer
(Recommend)
Serialize by symfony/serializer
and write the response body.
Preparer options:
Key | description |
---|---|
status | Http response code. |
headers | Http response headers. |
<more> |
$serializer->serialize context variables. |
The PrepareResult
attribute
Using #[PrepareResult]
attribute to select a preparer and pass the context.
Example for Mezzio :
Register route without attribute.
Using CallableHandlerAbstractFactory
register route.
Register abstract factory in laminas/laminias-servicemanager
.
ErrorHandler for mezzio
Rich error handling,
Response to json format
Throw exception in handler.
When request is ajax will response to json result:
logging errors
When errors occur, you may want to listen for them in order to provide features such as logging. See https://docs.mezzio.dev/mezzio/v3/features/error-handling/#listening-for-errors