Symfony config.yml can't load Twig extension

373 Views Asked by At

My config.yml is as follows:

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

I get an error:

 'The service definition "templating.engine.twig" does not exist.'

But the Twig extension is in the /vendor/twig folder. What more do I have to change to make it work?

1

There are 1 best solutions below

0
On

You have to register the TwigBundle and also configure it. An example can be seen in the Symfony Standard edition:

app/config/config.yml:

# Twig Configuration
twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"

app/AppKernel.php:

new Symfony\Bundle\TwigBundle\TwigBundle(),