Reputation: 8159
my question is quite simple, but I could not find an answer on google.
In my silex project I have a parameter that can be or not on my url, e.g.:
domain.com/?foo=1
When I use the method before it works fine:
$app->before(function (Request $request) use ($app) {
echo $app['request']->get('foo');
});
however if I have any variant of that url I can't catch it anymore. e.g.:
domain.com/contact?foo=1
domain.com/about?foo=1
domain.com/company?foo=1
...
I know, I could create a route for that.. But if I have 20, 30 different routers, it sounds insane for me change all of them.
Any help would be really appreciated. Cheers.
Upvotes: 1
Views: 502
Reputation: 8159
In the end the problem was in my NGINX. I changed this line
location / {
try_files $uri $uri/ /index.php;
}
To
location / {
try_files $uri $uri/ /index.php?$args;
}
Sorry all for this dummy question.
Upvotes: 1
Reputation: 758
You should be able to get the parameters normally like so:
$app->get(
'/contact',
function () use ($app) {
exit('foo: ' . $app['request']->get('foo'));
}
);
Upvotes: 0