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.