Refilon Refilon - 1 year ago 83
PHP Question

Symfony3 service not found by twig

I've got the following problem. I've got a service. And I want to use that service in every TWIG template. But it does not find my service.

I get the following error:

ServiceNotFoundException in CheckExceptionOnInvalidReferenceBehaviorPass.php line 58:
The service "twig" has a dependency on a non-existent service "appbundle\service\categoryhandler".

Notice that the service is not camelcased, while it is camelcased in my config.yml.

Here's my config.yml part

# Twig Configuration
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
categories: '@AppBundle\Service\CategoryHandler'

I already added PHP templating engine (found this 'solution' while googling my problem).

engines: ['twig', 'php']

I've followed this documentation of Symfony

Answer Source

Looks like it cannot find your CategoryHandler service.

Has it been registered? Or, has auto loading been enabled?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download