How to setup default routing in Symfony2?
In Symfony1 it looked something like this:
homepage:
url: /
param: { module: default, action: index }
de
If you want to create a "catch all", your best bet would be to hook on the KernelEvents::EXCEPTION
event. This event gets triggered whenever an Exception falls through to the HttpKernel
, this includes the NotFoundHttpException
thrown when the router cannot resolve a route to a Controller.
The effect would be similar to Symfony's stylized 404 page that gets rendered when you send the request through app_dev.php. Instead of returning a 404, you perform whatever logic you're looking to.