I know this is a big NO NO... and should not be displaying developer error pages while my site is live, what can I do to ensure dev environment error messages are not appearing in production?
Why are these appearing? I thought it was turned off by default when in production mode? Did I miss a setting?
Note: This is on a shared server. And am using the app.php not app_dev.php.
When I go to production mode locally it properly displays the right error messages (below):
Oops! An Error Occurred The server returned a "404 Not Found". Something is broken. Please e-mail us at [email] and let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.
Yet on the live site it's showing the Symfony2 dev environment error message?
I've tried to make a custom error message by making a error404.html.twig file in app/Resource/TwigBundle/views/Exception but it still doesn't load this file and just displays the developer error message.
In your frontend controller (web/app.php
in the Symfony Standard Edition), an instance of AppKernel
is created. AppKernel
inherits the constructor from Symfony's Kernel
, which requires two arguments:
/**
* Constructor.
*
* @param string $environment The environment
* @param bool $debug Whether to enable debugging or not
*/
public function __construct($environment, $debug)
The $environment
parameter only determines which configuration is used (config_dev.yml
, config_prod.yml
, etc.). The $debug
parameter is the one that enables or disables debugging (and therefore determines wether exceptions are shown or not).
So in app.php
, change:
$kernel = new AppKernel('prod', true);
to
$kernel = new AppKernel('prod', false);
This should replace the detailed exception pages with user-friendly error pages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With