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

Rob Allen:
Route specific configuration in Slim
Dec 13, 2018 @ 16:46:41

Rob Allen has posted a new tutorial to his site sharing how you can set up route specific configurations in Slim by setting it as a part of the route definition.

A friend emailed me recently asking about route specific configuration in Slim. He wants to be able to set properties when creating the route that he can pick up when the route is matched. The way to do this is using route arguments. I’ve written about route arguments before in the context of setting default values for a route parameter, but you can also use them to set new data for use later.

In this post, I’m going to look at how to use them for configuration data, such as setting required ACL permissions for routes.

He includes code snippets showing how to set the per-route data and how to access it from inside of the request handling via the Request instance. He shows an example of this both in the basic route definition and in middleware.

tagged: route configuration specific tutorial middleware

Link: https://akrabat.com/route-specific-configuration-in-slim/


Trending Topics: