Slim: Update route callable signature for PSR-15

Created on 19 Nov 2016  路  6Comments  路  Source: slimphp/Slim

Related to #2050

Has PR Slim 4

Most helpful comment

If you're going to continue using the array $args by default I'd recommend not adding them as request attributes. See #2019

We should look at that, certainly.

The route callable's signature is configuration via a strategy, so this ticket is for creating the new strategy to more closely match the PSR-15 signature.

All 6 comments

Will become:

$app->get('/foo', function (ServerRequest $request, array $args) {
    // Return response object
});

If you're going to continue using the array $args by default I'd recommend not adding them as request attributes. See #2019

If you're going to continue using the array $args by default I'd recommend not adding them as request attributes. See #2019

We should look at that, certainly.

The route callable's signature is configuration via a strategy, so this ticket is for creating the new strategy to more closely match the PSR-15 signature.

Hi!

According to the accepted PSR-15 specification the new signature should look like this.

$app->get('/foo', function (ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface {
    $response = $handler->handle($request);

    // Do something...

    // Return response object
    return $response;
});

Is this correct? Will the signature in Slim version 4 look like this?

Fixed in #2497

Was this page helpful?
0 / 5 - 0 ratings

Related issues

enygma picture enygma  路  3Comments

codeguy picture codeguy  路  4Comments

codeguy picture codeguy  路  3Comments

aranel616 picture aranel616  路  3Comments

JamesTheHacker picture JamesTheHacker  路  3Comments