Slim icon indicating copy to clipboard operation
Slim copied to clipboard

Question: Can a route be called into a variable

Open designermonkey opened this issue 13 years ago • 5 comments

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);?

designermonkey avatar Jun 28 '13 16:06 designermonkey

I do not know if it is possible, but something like that should be usefull to run unit tests on various routes I guess :)

trasher avatar Jun 29 '13 10:06 trasher

That's a really good use case too, I never thought of that one.

designermonkey avatar Jun 29 '13 18:06 designermonkey

This is not possible yet. It is a feature I hope to include in the next major version.

codeguy avatar Jun 29 '13 18:06 codeguy

Thanks for the reply, I will use controllers for now, and where I need to get the response, I'll call them directly.

designermonkey avatar Jun 29 '13 18:06 designermonkey

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?

zomble avatar Oct 08 '13 22:10 zomble