问题描述
自从我的 Symfony 2
更新到 2.7
.我在 PHPUnit
和 console
中发现了很多已弃用的错误(现在消息已经很清楚了).
Since my Symfony 2
update to 2.7
. I get a lot of deprecated erors in PHPUnit
and console
(message is clear by now).
ProjectXApiBundleTestsControllerSectionsControllerTest::testPostDebug()
The twig.form.resources configuration key is deprecated since version 2.6 and will be removed in 3.0. Use the twig.form_themes configuration key instead.
知道如何暂时禁用它们吗?
Any idea how to disable them for now?
推荐答案
我遇到了同样的问题,并通过类似于以下链接的方式解决了它.Symfony 声明报告所有错误并覆盖您按设计放入 php.ini 的内容(否则它无法捕获并为您显示好的堆栈跟踪).
I have the same problem and solved it similar to the below link. Symfony declares to report all errors and overrides what you put in php.ini by design (otherwise it couldn't catch & display nice stack traces for you).
因此,您需要通过在 AppKernel.php 中创建 init()
函数并设置 error_reporting 来覆盖 Symfony2 的内置错误报告,以及(可能)一些环境检测,以确保您不会在生产中显示错误,例如:
So, you'll need to override Symfony2's built-in error reporting by creating an init()
function in your AppKernel.php and setting the error_reporting how you'd like there, along with (probably) some environment detection to make sure you don't display errors in production, for example:
// Add this to app/AppKernel.php
public function init()
{
if ($this->debug) {
ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
} else {
ini_set('display_errors', 0);
}
}
此处有更多详细信息(如果您不会阅读俄语,请使用谷歌翻译:)http://tokarchuk.ru/2012/12/disable-deprecated-warnings-in-symfony-2/
More details here (use Google Translate if you do not read Russian :) http://tokarchuk.ru/2012/12/disable-deprecated-warnings-in-symfony-2/
这篇关于在 Symfony 2(.7) 中禁用已弃用的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!