Symfony2上下文错误:警告:filemtime():状态失败。

4

当我将应用程序部署到生产服务器时,生产环境即app.php页面出现了空白。

然而,我试图通过使用我的开发环境下的"*app_dev.php*"来找出问题,我注释了限制我的代码,然后出现以下错误:

ContextErrorException: 警告:文件修改时间获取失败,路径为
C:\xampp\htdocs\deploy\Demo\src\SoftMarshal\Bundle\MainBundle/Resources/views/Default/index.html.twig
在/var/www/web/bilyonedemo/htdocs/vendor/twig/twig/lib/Twig/Loader/Filesystem.php 的第165行 ContextErrorException: 警告:文件修改时间获取失败,路径为C:\xampp\htdocs\deploy\Demo\src\SoftMarshal\Bundle\MainBundle/Resources/views/Default/index.html.twig,在/var/www/web/bilyonedemo/htdocs/vendor/twig/twig/lib/Twig/Loader/Filesystem.php的第165行

in /var/www/web/bilyonedemo/htdocs/vendor/twig/twig/lib/Twig/Loader/Filesystem.php line 165
at ErrorHandler->handle('2', 'filemtime(): stat failed for C:\xampp\htdocs\deploy\Demo\src\SoftMarshal\Bundle\MainBundle/Resources/views/Default/index.html.twig', '/var/www/web/bilyonedemo/htdocs/vendor/twig/twig/lib/Twig/Loader/Filesystem.php', '165', array('name' => 'SoftMarshalMainBundle:Default:index.html.twig', 'time' => '1384444091'))
at filemtime('C:\xampp\htdocs\deploy\Demo\src\SoftMarshal\Bundle\MainBundle/Resources/views/Default/index.html.twig') in /var/www/web/bilyonedemo/htdocs/vendor/twig/twig/lib/Twig/Loader/Filesystem.php line 165
at Twig_Loader_Filesystem->isFresh('SoftMarshalMainBundle:Default:index.html.twig', '1384444091') in /var/www/web/bilyonedemo/htdocs/app/cache/dev/classes.php line 4582
at Twig_Environment->isTemplateFresh('SoftMarshalMainBundle:Default:index.html.twig', '1384444091') in /var/www/web/bilyonedemo/htdocs/app/cache/dev/classes.php line 4563
at Twig_Environment->loadTemplate('SoftMarshalMainBundle:Default:index.html.twig') in /var/www/web/bilyonedemo/htdocs/vendor/symfony/symfony/src/Symfony/Bridge/Twig/TwigEngine.php line 131
at TwigEngine->load('SoftMarshalMainBundle:Default:index.html.twig') in /var/www/web/bilyonedemo/htdocs/vendor/symfony/symfony/src/Symfony/Bridge/Twig/TwigEngine.php line 53
at TwigEngine->render('SoftMarshalMainBundle:Default:index.html.twig', array()) in /var/www/web/bilyonedemo/htdocs/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/TwigEngine.php line 79
at TwigEngine->render('SoftMarshalMainBundle:Default:index.html.twig', array()) in /var/www/web/bilyonedemo/htdocs/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Debug/TimedTwigEngine.php line 52
at TimedTwigEngine->render('SoftMarshalMainBundle:Default:index.html.twig', array()) in /var/www/web/bilyonedemo/htdocs/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/TwigEngine.php line 108
at TwigEngine->renderResponse('SoftMarshalMainBundle:Default:index.html.twig', array(), null) in /var/www/web/bilyonedemo/htdocs/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php line 106
at Controller->render('SoftMarshalMainBundle:Default:index.html.twig') in /var/www/web/bilyonedemo/htdocs/src/SoftMarshal/Bundle/MainBundle/Controller/DefaultController.php line 11
at DefaultController->indexAction()
at call_user_func_array(array(object(DefaultController), 'indexAction'), array()) in /var/www/web/bilyonedemo/htdocs/app/bootstrap.php.cache line 2844
at HttpKernel->handleRaw(object(Request), '1') in /var/www/web/bilyonedemo/htdocs/app/bootstrap.php.cache line 2818
at HttpKernel->handle(object(Request), '1', true) in /var/www/web/bilyonedemo/htdocs/app/bootstrap.php.cache line 2947
at ContainerAwareHttpKernel->handle(object(Request), '1', true) in /var/www/web/bilyonedemo/htdocs/app/bootstrap.php.cache line 2249
at Kernel->handle(object(Request)) in /var/www/web/bilyonedemo/htdocs/web/app_dev.php line 29

虽然在我的本地机器上运行良好。


尝试清除缓存。在给定的错误中,Symfony 尝试在 "C:\xampp\htdocs..." 找到模板,我认为这是您的本地路径,而不是服务器路径。 - a.tereschenkov
是的,KyleMit,你说得对,C:\xampp\htdocs.. 是我的本地路径,但它清除了缓存并预热了生产和开发环境,但我仍然遇到了额外的错误,因为评论文本区域的字符限制,我将其附加在问题上。感谢你的帮助。 - user2992896
看起来你的代码库中某处硬编码了该路径。你能否在项目中运行搜索“xampp”字符串?因为我不明白为什么Symfony会在服务器上使用你的本地路径。 - a.tereschenkov
2个回答

17
如果有帮助的话,清除缓存,然后通过composer重新安装供应商解决了我的问题:
php app/console cache:clear
php composer.phar install

0

我曾经遇到过同样的问题,这是由于我的xdebug配置中设置了错误处理参数。通过注释以下行来编辑xdebug配置(注释字符为分号“;”字符)。

; Error Handling
; xdebug.halt_level = E_WARNING
; xdebug.force_display_errors = 1
; xdebug.scream = 1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接