我的config.yml
如下:
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
#translator: { fallback: %locale% }
secret: %secret%
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_proxies: ~
session: ~
fragments: ~
http_method_override: true
我收到一个错误:
'The service definition "templating.engine.twig" does not exist.'
但是 Twig 扩展名位于 /vendor/twig
文件夹中。我还需要更改什么才能使其正常工作?
您必须注册 TwigBundle 并对其进行配置。在Symfony标准版中可以看到一个例子:
app/config/config.yml
:
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
app/AppKernel.php
:
new Symfony'Bundle'TwigBundle'TwigBundle(),