Releases: WonderNetwork/slim-kernel
2.0.2
2.0.1
Merge pull request #8 from WonderNetwork/fix/closure-serialization closures can’t reference self/$this in order for them to be serialized
2.0.0
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
1.7.0
Support glob patterns like **/*.php
to match any directory depth
1.6.0
add floats to array accessor
1.5.0
Allow configuring if symfony console application exits automatically by overriding the AutoExit::class
service
1.4.0
Simplify boilerplate around Symfony Console commands
1.3.0
For all those pesky cron jobs, where on one hand you’d like to silence the output because it causes noisy emails for no reason, but at the same time you don’t want to lose context when something bad happens. Wrap your commands in a FingersCrossedHandler
like so:
public function execute(InputInterface $input, OutputInterface $output): int {
return FingersCrossedHandler::of($input, $output)->run(
function (InputParams $input, FingersCrossedOutput $output) {
$output->write("Hello world!")
return 1;
},
);
}
The output will be silenced except for the following situatios:
- You increase the output verbosity using the
-v
flag or thesetVerbosity()
method - The command returns a non-zero exit code
- The command throws
In the former case, the output will be written in realtime, and in the two latter ones you can expect it writtein in bulk at the end.
1.2.2
Same as v1.2.1 but contains the code this time 😂
Represent RouteArgument
as ArrayAccessor
to enable type-casting.
Before:
$limit = RouteArgument::get($request, 'limit');
if (false === is_numeric($limit) {
throw new HttpBadRequestException($request);
}
$limit = (int) $limit;
After:
$limit = RouteArgument::of($request)->int('limit');
1.2.1
Represent RouteArgument
as ArrayAccessor
to enable type-casting.
Before:
$limit = RouteArgument::get($request, 'limit');
if (false === is_numeric($limit) {
throw new HttpBadRequestException($request);
}
$limit = (int) $limit;
After:
$limit = RouteArgument::of($request)->int('limit');