Symfony 4.3:用户已弃用:Symfony\Bundle\TwigBundle\Loader\FilesystemLoader 类自 4.3 版起已弃用,并将在 5.0 中删除…… [英] Symfony 4.3: User Deprecated: The Symfony\Bundle\TwigBundle\Loader\FilesystemLoader class is deprecated since version 4.3 and will be removed in 5.0 …

查看:45
本文介绍了Symfony 4.3:用户已弃用:Symfony\Bundle\TwigBundle\Loader\FilesystemLoader 类自 4.3 版起已弃用,并将在 5.0 中删除……的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

升级到 Symfony 4.3 后,我收到以下 22 条弃用警告:

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

User Deprecated:Symfony\Bundle\TwigBundle\Loader\FilesystemLoader 类从 4.3 版本开始被弃用,将在 5.0 中移除;使用 Twig 表示法代替模板.

User Deprecated: The Symfony\Bundle\TwigBundle\Loader\FilesystemLoader class is deprecated since version 4.3 and will be removed in 5.0; use Twig notation for templates instead.

用户已弃用:templating.locator" 服务自 Symfony 4.3 起已弃用,并将在 5.0 中删除.

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

User Deprecated:Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator 类从 4.3 版本开始被弃用,将在 5.0 中移除;改用 Twig.

User Deprecated: The Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

用户已弃用:templating.name_parser" 服务自 Symfony 4.3 起已弃用,并将在 5.0 中删除.

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

User Deprecated:Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser 类从 4.3 版本开始被弃用,将在 5.0 中移除;改用 Twig.

User Deprecated: The Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

用户已弃用:使用模板"服务自 4.3 版起已弃用,并将在 5.0 中删除;改用 Twig.

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

User Deprecated:Symfony\Bridge\Twig\TwigEngine 类从 4.3 版本开始被弃用,将在 5.0 中移除;改用 \Twig\Environment.

User Deprecated: The Symfony\Bridge\Twig\TwigEngine class is deprecated since version 4.3 and will be removed in 5.0; use \Twig\Environment instead.

User Deprecated:Symfony\Bundle\FrameworkBundle\Templating\EngineInterface 接口从 4.3 版本开始被弃用,将在 5.0 中移除;改用 Twig.

User Deprecated: The Symfony\Bundle\FrameworkBundle\Templating\EngineInterface interface is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

User Deprecated:Symfony\Bundle\TwigBundle\TwigEngine 类从 4.3 版本开始被弃用,将在 5.0 中移除;改用 \Twig\Environment.

User Deprecated: The Symfony\Bundle\TwigBundle\TwigEngine class is deprecated since version 4.3 and will be removed in 5.0; use \Twig\Environment instead.

2 次:自 Symfony 4.3 起不推荐使用 framework.templating" 配置.改为配置 Twig Bundle 提供的 twig" 部分.

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

启用模板组件自 4.3 版起已弃用,将在 5.0 中移除;改用 Twig.

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

templating.cache_warmer.template_paths" 服务自 Symfony 4.3 起已弃用,并将在 5.0 中移除.

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

Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplatePathsCacheWarmer 类自 4.3 版起已弃用,将在 5.0 中移除;改用 Twig.

The Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplatePathsCacheWarmer class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

templating.finder" 服务自 Symfony 4.3 起已弃用,并将在 5.0 中删除.

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

Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinder 类自 4.3 版起已弃用,将在 5.0 中移除;改用 Twig.

The Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinder class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface 接口从 4.3 版本开始被弃用,将在 5.0 中移除;改用 Twig.

The Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface interface is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

templating.locator" 服务自 Symfony 4.3 起已弃用,并将在 5.0 中移除.

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

Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator 类从 4.3 版本开始被弃用,将在 5.0 中移除;改用 Twig.

The Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

Symfony\Bundle\FrameworkBundle\Templating\TemplateReference 类自 4.3 版起已弃用,并将在 5.0 中移除;改用 Twig.

The Symfony\Bundle\FrameworkBundle\Templating\TemplateReference class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

templating.name_parser" 服务自 Symfony 4.3 起已弃用,并将在 5.0 中删除.

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

Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser 类自 4.3 版起已弃用,并将在 5.0 中移除;改用 Twig.

The Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

推荐答案

这是由于模板组件已弃用,请参阅 https://symfony.com/blog/new-in-symfony-4-3-deprecated-the-templating-component-integration

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

解决方案:

  1. composer.json
  2. 中删除 "symfony/templating"
  3. framework.yaml 中删除:
templating:
    engines:
        - twig

  • 运行composer update
  • 这应该会删除所有弃用警告.

    This should remove all the deprecation warnings.

    如果您收到此错误

    无法自动装配服务...":方法__construct()"的参数$templating"引用接口Symfony\Bundle\FrameworkBundle\Templating\EngineInterface",但不存在这样的服务.您是否创建了实现此接口的类?

    Cannot autowire service "...": argument "$templating" of method "__construct()" references interface "Symfony\Bundle\FrameworkBundle\Templating\EngineInterface" but no such service exists. Did you create a class that implements this interface?

    ...您仍在某些服务中使用旧模板.
    解决方案:将依赖从Symfony\Bundle\FrameworkBundle\Templating\EngineInterface 改为Twig\Environment:

    ... you're still using the old templating in some service.
    Solution: Change the dependency from Symfony\Bundle\FrameworkBundle\Templating\EngineInterface to Twig\Environment:

    use Twig\Environment;
    
    private $twig;
    
    public function __construct(Environment $twig)
    {
        $this->twig = $twig;
    }
    

    另见https://github.com/symfony/symfony/issues/31645

    这篇关于Symfony 4.3:用户已弃用:Symfony\Bundle\TwigBundle\Loader\FilesystemLoader 类自 4.3 版起已弃用,并将在 5.0 中删除……的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆