Skip to content

Releases: WonderNetwork/slim-kernel

2.0.2

04 Feb 20:37
8ca150a
Compare
Choose a tag to compare
Merge pull request #9 from WonderNetwork/feature/upgrade-deps

composer update

2.0.1

03 Feb 15:58
869966e
Compare
Choose a tag to compare
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

28 Jan 19:17
90f1f44
Compare
Choose a tag to compare

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

18 Dec 10:03
1b2aa46
Compare
Choose a tag to compare

Support glob patterns like **/*.php to match any directory depth

1.6.0

06 Dec 10:37
502fd07
Compare
Choose a tag to compare

add floats to array accessor

1.5.0

25 Nov 20:51
025a906
Compare
Choose a tag to compare

Allow configuring if symfony console application exits automatically by overriding the AutoExit::class service

1.4.0

07 Nov 07:47
85a96d4
Compare
Choose a tag to compare

Simplify boilerplate around Symfony Console commands

1.3.0

06 Nov 09:45
a05736d
Compare
Choose a tag to compare

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 the setVerbosity() 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

25 Oct 09:01
Compare
Choose a tag to compare

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

25 Oct 08:58
Compare
Choose a tag to compare

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');