Why does the Symfony @templating service provide different classes in dev and prod?

I had a service that worked perfectly in dev. It looked something like this:

use Symfony\Bundle\TwigBundle\TwigEngine;

public function __construct(TwigEngine $twig)
{
    $this->twig = $twig;
}

// service methods here

I create an instance in services.ymlby passing it @templating.

Everything worked fine in dev, but in our intermediate environment (which uses the Symfony environment prod), I saw a 500 error saying that the argument

must be an instance of Symfony\Bundle\TwigBundle\TwigEngine

but instead ...

instance of Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine given.

I solved this by completing the sentence of this report on related sex errors and typing instead Symfony\Bundle\FrameworkBundle\Templating\EngineInterface.

However, I would like to know why this happens - why the instance is TwigEnginepassed in dev(and test) but DelegatingEnginein prod?

The corresponding lines from mine config.ymlare as follows:

framework:
    templating: { engines: ['twig'] }

( engines: 'twig' - , , ), .)

- , ?

+4
1

Symfony @Template(engine='foo') (doc).

:

(, , ..). dev .

, .

, prod/dev.

Engine . . TimedPhpEngine.

0

All Articles