我刚刚更新了一个Symfony 2.7项目到2.8。现在,我准备将项目更新到Symfony 3。配置文件显示,每个请求都使用了大量(超过1500)不推荐的方法/类。
当然,我想解决这些问题。然而,据我所知,废弃的代码是由Symfony本身使用的,而不是由我自己的代码使用的。
下面是一个示例:
ConfigCache::__toString() is deprecated since version 2.7 and will be removed in 3.0. Use the getPath() method instead. (4 times)
ConfigCache::__toString() (called from AllowedMethodsRouterLoader.php at line 51)
AllowedMethodsRouterLoader::getAllowedMethods() (called from AllowedMethodsRouterLoader.php at line 51)
AllowedMethodsRouterLoader::getAllowedMethods() (called from AllowedMethodsListener.php at line 41)
AllowedMethodsListener::onKernelResponse()
call_user_func() (called from WrappedListener.php at line 61)
WrappedListener::__invoke()
call_user_func() (called from EventDispatcher.php at line 184)
...a lot more Twig calls...
Twig_Template::displayWithErrorHandling() (called from Template.php at line 347)
Twig_Template::display() (called from Template.php at line 358)
Twig_Template::render() (called from TwigEngine.php at line 50)
TwigEngine::render() (called from TwigEngine.php at line 72)
TwigEngine::render() (called from TwigEngine.php at line 97)
TwigEngine::renderResponse() (called from Controller.php at line 185)
Controller::render() (called from RegistrationController.php at line 71)
RegistrationController::registerAction()
call_user_func_array() (called from HttpKernel.php at line 144)
HttpKernel::handleRaw() (called from HttpKernel.php at line 64)
HttpKernel::handle() (called from ContainerAwareHttpKernel.php at line 69)
ContainerAwareHttpKernel::handle() (called from Kernel.php at line 185)
Kernel::handle() (called from app_dev.php at line 37)
当然,我自己的代码也涉及到这个调用堆栈:RegistrationController
处理请求并使用Twig
模板呈现页面。但是,使用不推荐的ConfigCache::__toString()
方法的代码来自AllowedMethodsRouterLoader
类,这是Symfony的一部分。
,我的代码能做些什么来避免这种不推荐的代码吗?
我很惊讶,Symfony代码本身使用了不推荐的代码。有没有办法过滤掉这些消息,并且只在我自己的代码中得到关于弃用的通知?
发布于 2016-09-30 19:26:11
您可能对Sensio实验室( Symfony的创建者)的弃用检测器感兴趣。
在2.8中,我使用了相当多的删除不推荐的类/方法,准备迁移到3.0。是个伟大的节省时间的人。强烈推荐。
我还建议使用Symfony升级修补程序来节省更多的时间,特别是在表单类方面。
发布于 2016-09-30 11:38:36
它正在运行废弃的代码--在Symfony代码库中,但是它是从Twig调用的。因为Twig是Symfony的头等舱,而不是Symfony项目的正式部分,所以它有自己的版本。一个最新版本的Twig以及其他库将删除弃用代码的使用,或者至少为改善状态做些事情。
因此,更新基于Symfony框架的项目的很大一部分,也是更新其他也正在使用的库。仅仅更新composer.json中的composer.json行是不够的。
https://stackoverflow.com/questions/39789788
复制