Answer the question
In order to leave comments, you need to log in
How to implement a route like /method?par1=val1&...&parn=valn in Slim Framework?
/method/val1/val2/.../valn
If I understood correctly from the documentation, the view routes
are welcomed by the framework /method?par1=val1&...&parn=valn
.
$app->get('/method', 'callback_function');
function callback_function() {
GLOBAL $app;
$par1 = $_GET['par1'];
$par2 = $_GET['par2'];
}
Answer the question
In order to leave comments, you need to log in
There is nothing strange or scary about the declaration of the global $app, as far as I know. There is no other way to get to it anyway.
If you have fresh PHP, then you can do something like this
$app->get('/method', function() use ($app) {
$app->request->params('par1');
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question