Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Rob Allen:
Default route arguments in Slim
Jun 14, 2017 @ 14:48:51

Rob Allen has posted a quick tip for the Slim framework users out there showing how to use default route arguments in your application.

A friend of mine recently asked how to do default route arguments and route specific configuration in Slim, so I thought I'd write up how to do it.

He illustrates with a simple "Hello world" route that responds using the "name" value from the URL path. He then shows how to modify this example and define a default using the "setArgument" method on the route itself (for both single and multiple values). He ends with an example of how it can be applied for other values needed in the route as well, like a "role" for access control handling.

tagged: slim framework default route arguments tutorial setargument

Link: https://akrabat.com/default-route-arguments-in-slim/


Trending Topics: