zm455
zm455

Reputation: 499

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) ?

Upvotes: 0

Views: 3756

Answers (2)

Sergey Fedorov
Sergey Fedorov

Reputation: 1

In the new Symfony version, there is a new var APP_DEBUG, which you send to Kernel in the second parameter. Just add new var to your .env file

APP_DEBUG=false

return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);

Upvotes: 0

Wouter J
Wouter J

Reputation: 41934

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.

Upvotes: 3

Related Questions