Slim: Routing: methods must be in uppercase since v4 ?!

Created on 4 Oct 2020  路  4Comments  路  Source: slimphp/Slim

slim v3: working without problems:

$app->map(array("get","post"), "/test", "TestController:test")->setName("test");

slim v4: error

$app->map(array("get","post"), "/test", "TestController:test")->setName("test");

Solution: "simply" change all methods to uppercase

$app->map(array("GET","POST"), "/test", "TestController:test")->setName("test");

WHY ?!

that is an array of strings and it does not mapper, if strings are case-sensivtive for this part.
we have thousands of routes (and no, there is no way to bundle them, it's just a big and complex app) and we use UPPERCASE only for const and defined values ... not for string arrays.

2nd reason, why we are not quiclly able to change all to UPPERCASE: some automatic procedures, which are documenting our sources, have to be changed and that would brings lot more work for us. we changes the map function in the slim sources to accept lower strings and there seems not be any problems. so, why has this be changed ?

pls change that back to enable us, using slim in future.

Most helpful comment

Hi @snoopy72 I have checked the Slim 3, 4 and FastRoute documetation about this specific parameter.

v3: http://www.slimframework.com/docs/v3/objects/router.html#custom-route
v4: http://www.slimframework.com/docs/v4/objects/routing.html#custom-route
Fastroute: https://github.com/nikic/FastRoute#defining-routes

All pages shows that the HTTP method name must be written in UPPERCASE.

Slim 3:

$app->map(['GET', 'POST'], '/books', function ($request, $response, $args) {
    // ...
});

Slim 4:

$app->map(['GET', 'POST'], '/books', function ($request, $response, $args) {
    // ...
});

Fastroute:

$r->addRoute(['GET', 'POST'], '/test', 'handler');

we use UPPERCASE only for const and defined values ... not for string arrays.

Just because this "rule" applies to your company or solution does not mean that this rule applies equally to everyone else out there, and certainly not to libraries or frameworks.

change that back to enable us, using slim in future.

I think lowercase for the HTTP methods was never so documented and officially supported.
The documentation is not perfect, but in this case it looks quite correct to me.

All 4 comments

FastRoute handles route matching. You can go complain over on that repo.

I suggest that you change your tone. It's rather abrasive.

I suggest that you change your documentation and way of upgrading. It's really frustrating and annoying.

btw: FastRoute did not change (v1.3.0 in both systems).

It's your code (vendor/slim/slim/Slim/Routing/RouteCollector.php) which seems to be responsible for this problem.

Pointing the finger is easy ... the "map" function is defined in your source.

Hi @snoopy72 I have checked the Slim 3, 4 and FastRoute documetation about this specific parameter.

v3: http://www.slimframework.com/docs/v3/objects/router.html#custom-route
v4: http://www.slimframework.com/docs/v4/objects/routing.html#custom-route
Fastroute: https://github.com/nikic/FastRoute#defining-routes

All pages shows that the HTTP method name must be written in UPPERCASE.

Slim 3:

$app->map(['GET', 'POST'], '/books', function ($request, $response, $args) {
    // ...
});

Slim 4:

$app->map(['GET', 'POST'], '/books', function ($request, $response, $args) {
    // ...
});

Fastroute:

$r->addRoute(['GET', 'POST'], '/test', 'handler');

we use UPPERCASE only for const and defined values ... not for string arrays.

Just because this "rule" applies to your company or solution does not mean that this rule applies equally to everyone else out there, and certainly not to libraries or frameworks.

change that back to enable us, using slim in future.

I think lowercase for the HTTP methods was never so documented and officially supported.
The documentation is not perfect, but in this case it looks quite correct to me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grikdotnet picture grikdotnet  路  54Comments

l0gicgate picture l0gicgate  路  27Comments

feryardiant picture feryardiant  路  20Comments

akrabat picture akrabat  路  43Comments

zyx-rd picture zyx-rd  路  19Comments