我在模板上出现错误“阻止”标题“SonataPageBundle :: base_error.html.twig”不存在。 “当我尝试访问http://localhost:8000/时。我正在尝试启动一个配置了sonata admin bundle和sonata page bundle的项目,这些是我的项目在symfony(composer.json)中的一些依赖项:
PHP 7.1.8 Symfony 3.3.8
"require": {
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"friendsofsymfony/rest-bundle": "^2.2",
"incenteev/composer-parameter-handler": "^2.0",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^3.0.2",
"sonata-project/admin-bundle": "^3.23",
"sonata-project/cache-bundle": "^2.3",
"sonata-project/datagrid-bundle": "^2.2",
"sonata-project/doctrine-orm-admin-bundle": "^3.1",
"sonata-project/easy-extends-bundle": "^2.2",
"sonata-project/notification-bundle": "^3.1",
"sonata-project/page-bundle": "^3.5",
"sonata-project/seo-bundle": "^2.2",
"symfony-cmf/routing-bundle": "^2.0",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.3.10",
"symfony/symfony": "3.3.*",
"twig/twig": "^1.0||^2.0"
},
这是错误堆栈跟踪:
Twig_Error_Runtime:
Block "title" on template "SonataPageBundle::base_error.html.twig" does not exist.
at vendor\sonata-project\page-bundle\Resources\views\base_error.html.twig:11
at Twig_Template->displayBlock('title', array('exception' => object(InternalErrorException), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_admin' => object(GlobalVariables), 'sonata_page' => object(GlobalVariables)), array('page_stylesheets' => array(object(__TwigTemplate_626d3c7ea09d945dea3e3ced9062d6a059ed90c3731a85afe587b65d9135355b), 'block_page_stylesheets'), 'content' => array(object(__TwigTemplate_92a22adb7096a00b0799bd4759bdde6bb47abc78e12c93295c06f6a96de5ba5a), 'block_content')), true)
(vendor\twig\twig\lib\Twig\Template.php:254)
at Twig_Template->renderBlock('title', array('exception' => object(InternalErrorException), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_admin' => object(GlobalVariables), 'sonata_page' => object(GlobalVariables)), array('page_stylesheets' => array(object(__TwigTemplate_626d3c7ea09d945dea3e3ced9062d6a059ed90c3731a85afe587b65d9135355b), 'block_page_stylesheets'), 'content' => array(object(__TwigTemplate_92a22adb7096a00b0799bd4759bdde6bb47abc78e12c93295c06f6a96de5ba5a), 'block_content')))
(var\cache\dev\twig\a4\a4a167564b475b5c6ead2ae566a2cfcbb882dc2de2df7ff848f92fa5b57b1a21.php:27)
at __TwigTemplate_626d3c7ea09d945dea3e3ced9062d6a059ed90c3731a85afe587b65d9135355b->doDisplay(array('exception' => object(InternalErrorException), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_admin' => object(GlobalVariables), 'sonata_page' => object(GlobalVariables)), array('page_stylesheets' => array(object(__TwigTemplate_626d3c7ea09d945dea3e3ced9062d6a059ed90c3731a85afe587b65d9135355b), 'block_page_stylesheets'), 'content' => array(object(__TwigTemplate_92a22adb7096a00b0799bd4759bdde6bb47abc78e12c93295c06f6a96de5ba5a), 'block_content')))
(vendor\twig\twig\lib\Twig\Template.php:389)
at Twig_Template->displayWithErrorHandling(array('exception' => object(InternalErrorException), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_admin' => object(GlobalVariables), 'sonata_page' => object(GlobalVariables)), array('page_stylesheets' => array(object(__TwigTemplate_626d3c7ea09d945dea3e3ced9062d6a059ed90c3731a85afe587b65d9135355b), 'block_page_stylesheets'), 'content' => array(object(__TwigTemplate_92a22adb7096a00b0799bd4759bdde6bb47abc78e12c93295c06f6a96de5ba5a), 'block_content')))
(vendor\twig\twig\lib\Twig\Template.php:366)
at Twig_Template->display(array('exception' => object(InternalErrorException), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_admin' => object(GlobalVariables), 'sonata_page' => object(GlobalVariables)), array('content' => array(object(__TwigTemplate_92a22adb7096a00b0799bd4759bdde6bb47abc78e12c93295c06f6a96de5ba5a), 'block_content')))
(var\cache\dev\twig\89\8910d15eec17e5054a2c6abc9ebc366c887c2ca4519f4cc11e0a2a9ab49f42c3.php:30)
at __TwigTemplate_92a22adb7096a00b0799bd4759bdde6bb47abc78e12c93295c06f6a96de5ba5a->doDisplay(array('exception' => object(InternalErrorException), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_admin' => object(GlobalVariables), 'sonata_page' => object(GlobalVariables)), array('content' => array(object(__TwigTemplate_92a22adb7096a00b0799bd4759bdde6bb47abc78e12c93295c06f6a96de5ba5a), 'block_content')))
(vendor\twig\twig\lib\Twig\Template.php:389)
at Twig_Template->displayWithErrorHandling(array('exception' => object(InternalErrorException), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_admin' => object(GlobalVariables), 'sonata_page' => object(GlobalVariables)), array('content' => array(object(__TwigTemplate_92a22adb7096a00b0799bd4759bdde6bb47abc78e12c93295c06f6a96de5ba5a), 'block_content')))
(vendor\twig\twig\lib\Twig\Template.php:366)
at Twig_Template->display(array('exception' => object(InternalErrorException)))
(vendor\twig\twig\lib\Twig\Template.php:374)
at Twig_Template->render(array('exception' => object(InternalErrorException)))
(vendor\symfony\symfony\src\Symfony\Bridge\Twig\TwigEngine.php:49)
at Symfony\Bridge\Twig\TwigEngine->render('SonataPageBundle::internal_error.html.twig', array('exception' => object(InternalErrorException)))
(vendor\symfony\symfony\src\Symfony\Bundle\TwigBundle\TwigEngine.php:45)
at Symfony\Bundle\TwigBundle\TwigEngine->render('SonataPageBundle::internal_error.html.twig', array('exception' => object(InternalErrorException)))
(vendor\sonata-project\page-bundle\Listener\ExceptionListener.php:192)
at Sonata\PageBundle\Listener\ExceptionListener->handleInternalError(object(GetResponseForExceptionEvent))
(vendor\sonata-project\page-bundle\Listener\ExceptionListener.php:178)
at Sonata\PageBundle\Listener\ExceptionListener->onKernelException(object(GetResponseForExceptionEvent), 'kernel.exception', object(TraceableEventDispatcher))
at call_user_func(array(object(ExceptionListener), 'onKernelException'), object(GetResponseForExceptionEvent), 'kernel.exception', object(TraceableEventDispatcher))
(vendor\symfony\symfony\src\Symfony\Component\EventDispatcher\Debug\WrappedListener.php:104)
at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(GetResponseForExceptionEvent), 'kernel.exception', object(ContainerAwareEventDispatcher))
at call_user_func(object(WrappedListener), object(GetResponseForExceptionEvent), 'kernel.exception', object(ContainerAwareEventDispatcher))
(vendor\symfony\symfony\src\Symfony\Component\EventDispatcher\EventDispatcher.php:212)
at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.exception', object(GetResponseForExceptionEvent))
(vendor\symfony\symfony\src\Symfony\Component\EventDispatcher\EventDispatcher.php:44)
at Symfony\Component\EventDispatcher\EventDispatcher->dispatch('kernel.exception', object(GetResponseForExceptionEvent))
(vendor\symfony\symfony\src\Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher.php:146)
at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch('kernel.exception', object(GetResponseForExceptionEvent))
(vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php:230)
at Symfony\Component\HttpKernel\HttpKernel->handleException(object(InternalErrorException), object(Request), 1)
(vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php:79)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
(vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php:171)
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
(web\app_dev.php:29)
at require('C:\\...
答案 0 :(得分:0)
这是SonataPageBundle提供的模板中的错误(请参阅https://github.com/sonata-project/SonataPageBundle/pull/860)。作为解决方法,您可以将Twig安装降级为1.x:
composer update --with-dependencies twig/twig:^1.34