Skip to content
Advertisement

Symfony 4.3: User Deprecated: The SymfonyBundleTwigBundleLoaderFilesystemLoader class is deprecated since version 4.3 and will be removed in 5.0 …

After upgrading to Symfony 4.3, I’m getting the following 22 deprecation warnings:

User Deprecated: The SymfonyBundleTwigBundleLoaderFilesystemLoader class is deprecated since version 4.3 and will be removed in 5.0; use Twig notation for templates instead.

User Deprecated: The “templating.locator” service is deprecated since Symfony 4.3 and will be removed in 5.0.

User Deprecated: The SymfonyBundleFrameworkBundleTemplatingLoaderTemplateLocator class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

User Deprecated: The “templating.name_parser” service is deprecated since Symfony 4.3 and will be removed in 5.0.

User Deprecated: The SymfonyBundleFrameworkBundleTemplatingTemplateNameParser class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

User Deprecated: Using the “templating” service is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

User Deprecated: The SymfonyBridgeTwigTwigEngine class is deprecated since version 4.3 and will be removed in 5.0; use TwigEnvironment instead.

User Deprecated: The SymfonyBundleFrameworkBundleTemplatingEngineInterface interface is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

User Deprecated: The SymfonyBundleTwigBundleTwigEngine class is deprecated since version 4.3 and will be removed in 5.0; use TwigEnvironment instead.

2 times: The “framework.templating” configuration is deprecated since Symfony 4.3. Configure the “twig” section provided by the Twig Bundle instead.

Enabling the Templating component is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

The “templating.cache_warmer.template_paths” service is deprecated since Symfony 4.3 and will be removed in 5.0.

The SymfonyBundleFrameworkBundleCacheWarmerTemplatePathsCacheWarmer class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

The “templating.finder” service is deprecated since Symfony 4.3 and will be removed in 5.0.

The SymfonyBundleFrameworkBundleCacheWarmerTemplateFinder class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

The SymfonyBundleFrameworkBundleCacheWarmerTemplateFinderInterface interface is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

The “templating.locator” service is deprecated since Symfony 4.3 and will be removed in 5.0.

The SymfonyBundleFrameworkBundleTemplatingLoaderTemplateLocator class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

The SymfonyBundleFrameworkBundleTemplatingTemplateReference class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

The “templating.name_parser” service is deprecated since Symfony 4.3 and will be removed in 5.0.

The SymfonyBundleFrameworkBundleTemplatingTemplateNameParser class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

Advertisement

Answer

This is due to the deprecation of the templating component, see https://symfony.com/blog/new-in-symfony-4-3-deprecated-the-templating-component-integration

Solution:

  1. Remove "symfony/templating" from composer.json
  2. Remove this from framework.yaml:
    templating:
        engines:
            - twig
    
  3. Run composer update

This should remove all the deprecation warnings.

If you’re getting this error

Cannot autowire service “…”: argument “$templating” of method “__construct()” references interface “SymfonyBundleFrameworkBundleTemplatingEngineInterface” but no such service exists. Did you create a class that implements this interface?

… you’re still using the old templating in some service.
Solution: Change the dependency from SymfonyBundleFrameworkBundleTemplatingEngineInterface to TwigEnvironment:

use TwigEnvironment;

private $twig;

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

See also https://github.com/symfony/symfony/issues/31645

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement