zm455 zm455 - 3 months ago 23
PHP Question

Symfony: disable exceptions in prod mode

I'm a beginner with Symfony.

I have a Symfony 3.1 project. I put y project on my remote server. Everything works fine. Then I use SensioLabsInsight to check errors in my project. This analyse tool gives me those 2 warnings messages

:
"Exceptions should not be enabled in production" and "Symfony applications should not contain a config.php file"

Then my first question is how can I disable Exceptions in production ?
My second question is may I remove the config.php file in production (located in myBundle/web/config.php) ?

Answer

Then my first question is how can I disable Exceptions in production ?

As far as I can see when searching this on Google, I think it's because the second parameter passed to new AppKernel('prod', ...); is true, which enables debug mode. Set it to false. (same applies to debug settings in config_prod.yml).

My second question is may I remove the config.php file in production (located in myBundle/web/config.php) ?

Yes, also remove any front-controller (like app_dev.php) except from your production one. Remember: The standard edition is just a recommendation. Symfony doesn't force you any file or directory in the directory structure.