Question: Can a route be called into a variable
I'm new to Slim, and still getting to grips with whether it's right for my upcoming project. ALl looks great so far, just what I need.
A question sticks out for me, regarding routes and the functionality around them.
I can call a route by using curl or a browser for instance, but can a route be called in php so the response can be cached in a variable?
A little background: The app I'm building can output data in a variety of formats, but the whole thing is centralised around routes. If a route is called requesting json, then json is returned, as with xml, html etc, and also php. In the case of the php, I need to let the route just return a value, so this can be cached in a variable.
So, question is (simplified), can a route be called by passing a string as the uri, and a method like POST to a function like $result = $app->call('uri/string/here', 'post', $someParamsLikePostOrSomething);?
I do not know if it is possible, but something like that should be usefull to run unit tests on various routes I guess :)
That's a really good use case too, I never thought of that one.
This is not possible yet. It is a feature I hope to include in the next major version.
Thanks for the reply, I will use controllers for now, and where I need to get the response, I'll call them directly.
Hey guys, I'd preference $app->call(method, url); and expect Slim Environment to take care of parameters / client variables.
Simply because that's more inline with slim's operation, and parameter ordering.
Thoughts?