我正在使用Symfony 2.8,我试图在所有Twig模板中注入变量,因为文档说here所以我在app/config/config.yml
进行了更改:
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
globals:
admin_skin: "%admin_skin%"
和app/config/parameters.yml
:
admin_skin: skin-blue-light
但我以这个错误结束了:
您已请求不存在的参数" admin_skin"。
这就是日志所说的:
in ParameterBag.php line 94
at ParameterBag->get('admin_skin') in ParameterBag.php line 214
at ParameterBag->resolveString('%admin_skin%', array('admin_skin' => true)) in ParameterBag.php line 185
at ParameterBag->resolveValue('%admin_skin%', array()) in ParameterBag.php line 175
at ParameterBag->resolveValue(array('admin_skin' => '%admin_skin%'), array()) in ParameterBag.php line 175
at ParameterBag->resolveValue(array('debug' => '%kernel.debug%', 'strict_variables' => '%kernel.debug%', 'globals' => array('admin_skin' => '%admin_skin%')), array()) in ParameterBag.php line 175
at ParameterBag->resolveValue(array(array('form' => array('resources' => array('AvanzuAdminThemeBundle:layout:form-theme.html.twig')), 'globals' => array('admin_theme' => '@avanzu_admin_theme.theme_manager')), array('debug' => '%kernel.debug%', 'strict_variables' => '%kernel.debug%', 'globals' => array('admin_skin' => '%admin_skin%')))) in MergeExtensionConfigurationPass.php line 45
at MergeExtensionConfigurationPass->process(object(ContainerBuilder)) in MergeExtensionConfigurationPass.php line 39
at MergeExtensionConfigurationPass->process(object(ContainerBuilder)) in Compiler.php line 107
at Compiler->compile(object(ContainerBuilder)) in ContainerBuilder.php line 589
at ContainerBuilder->compile() in Kernel.php line 511
at Kernel->initializeContainer() in Kernel.php line 133
at Kernel->boot() in Kernel.php line 182
at Kernel->handle(object(Request)) in app_dev.php line 30
这在Symfony 2.8中有所改变,我不知道?我在这里错过了什么吗?我的错误在哪里?
如果我直接在app/config/config.yml
中设置值,则按以下方式运行:
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
globals:
admin_skin: skin-blue-light