Prevent site going down when route does not exist

Posted 3 months ago by chilitomato

By default it seems that an exception is thrown and view rendering is terminated when you call route() and the route does not exist.

The behavior is great for development, but for production what I would prefer is that if the env=production, instead of throwing an exception, route() just returns an empty string. This would prevent a scenario, for example, where the codebase was updated to add a new route, but somebody forgot to call artisan route:cache, thus taking the whole site down.

Is there an easy / clean way to allow route() to silently fail in production?

Please sign in or create an account to participate in this conversation.