Symfony:在生产模式下禁用异常 [英] Symfony: disable exceptions in prod mode

查看:70
本文介绍了Symfony:在生产模式下禁用异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Symfony的初学者.

I'm a beginner with Symfony.

我有一个Symfony 3.1项目.我将y项目放在我的远程服务器上.一切正常.然后,我使用SensioLabsInsight检查项目中的错误.此分析工具为我提供了这2条警告消息

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

:不应在生产中启用异常"和"Symfony应用程序不应包含config.php文件"

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

然后我的第一个问题是如何在生产中禁用异常?我的第二个问题是我可以删除生产环境中的config.php文件(位于myBundle/web/config.php中)吗?

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

推荐答案

然后我的第一个问题是如何在生产中禁用异常?

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

据我在Google上搜索时所看到的,我认为这是因为传递给 new AppKernel('prod',...); 的第二个参数是 true ,启用调试模式.将其设置为 false .(同样适用于 config_prod.yml 中的调试设置).

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

我的第二个问题是我可以删除生产中的config.php文件(位于myBundle/web/config.php中)吗?

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

是的,还要从生产环境中删除任何前控制器(例如 app_dev.php ).切记:标准版只是一个建议.Symfony不会在目录结构中强制您使用任何文件或目录.

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.

这篇关于Symfony:在生产模式下禁用异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆