我正在为我的symfony项目安装捆绑LiipImagineBundle。 我在内核中添加了它,配置它:
liip_imagine:
resolvers:
default:
web_path: ~
filter_sets:
avatar:
quality: 75
cache: ~
filters:
thumbnail: { size: [120, 120], mode: outbound }
当我启动带有表单的页面时,我收到了这个错误:
Unable to find template "LiipImagineBundle:Form:form_div_layout.html.twig" (looked into: /Users/user/www/html/project/app/Resources/views, /Users/user/www/html/project/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form).
为什么?你能帮我找到问题吗?当我删除LiipImagineBundle的配置和内核时,它又重新运行了。
先谢谢,
编辑: 我正在研究symfony的v3.4.1。
"php": ">=5.5.9",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"incenteev/composer-parameter-handler": "^2.0",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^5.0.0",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.6.4",
"symfony/symfony": "3.4.*",
"twig/twig": "^1.0||^2.0",
"jms/serializer-bundle": "^2.3.0",
"friendsofsymfony/elastica-bundle": "^4.0.1",
"friendsofsymfony/rest-bundle": "^2.3.0",
"friendsofsymfony/user-bundle": "^2.0.2",
"stof/doctrine-extensions-bundle": "^1.2.2",
"doctrine/doctrine-migrations-bundle": "^1.3.1",
"lexik/maintenance-bundle": "^2.1.2",
"liip/imagine-bundle": "^1.9.1",
"nelmio/api-doc-bundle": "^2.13.3",
"nietonfir/google-recaptcha-bundle": "^0.2.1",
"beberlei/DoctrineExtensions": "^1.0.20"
答案 0 :(得分:2)
我能够重现这个问题并找到了解决问题的方法。
# LiipImagineExtension.php
$resources = $container->hasParameter('twig.form.resources') ?
$container->getParameter('twig.form.resources') : array();
// The existing line
//$resources[] = 'LiipImagineBundle:Form:form_div_layout.html.twig';
// Change to
$resources[] = '@LiipImagine/Form/form_div_layout.html.twig';
$container->setParameter('twig.form.resources', $resources);
所以沿着S3.4的某个地方似乎已经改变了一些只使用twig名称空间而不是冒号表示法。对于Symfony来说,这是一次奇怪的BC休息。
我检查了liip github。这实际上是在未发布的2.0分支中修复的。考虑更新为“liip / imagine-bundle”:“^ 2.0.dev”,
这也可以通过配置框架使用twig来解决:
# app/config/config.yml
framework:
templating:
engines: ['twig']
答案 1 :(得分:1)
只有在Liip\ImagineBundle\LiipImagineBundle(
之后添加新的Symfony\Bundle\TwigBundle\TwigBundle()
),问题才存在。
安装指南应强调一个事实,即不应该在捆绑后装入捆绑软件。
在AppKernel.php中:
// ...
new Liip\ImagineBundle\LiipImagineBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
// ...
显然,此问题已在当前最新的2.x版本中解决