Skip to content

2.0.0

Compare
Choose a tag to compare
@mlebkowski mlebkowski released this 28 Jan 19:17
· 4 commits to main since this release
90f1f44

Input parsing

In order to simplify input parsing, you can use the Symfony Serializer component to
automatically denormalize parsed request body or get params to a data transfer object
of your choice. In your controller, simply mark one of the parameters with #[Payload]
attribute and typehint it with your desired class:

public function __invoke(#[WonderNetwork\SlimKernel\Http\Serializer\Payload] MyDto $input) {}

If the serializer fails to denormalize the input, a HttpBadRequestException will be
thrown with a semi-helpful message attached. If you require custom serializer setup,
you can register your own instance using the following container key:

\WonderNetwork\SlimKernel\ServiceFactory\SlimServiceFactory::INPUT_DENORMALIZER