gpt4 book ai didi

php - Symfony 4.3 : User Deprecated: The Symfony\Bundle\TwigBundle\Loader\FilesystemLoader class is deprecated since version 4. 3 并将在 5.0 中删除...

转载 作者:行者123 更新时间:2023-12-02 01:30:43 32 4
gpt4 key购买 nike

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

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.

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

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.

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

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.

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 Symfony\Bridge\Twig\TwigEngine class is deprecated since version 4.3 and will be removed in 5.0; use \Twig\Environment instead.

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: The Symfony\Bundle\TwigBundle\TwigEngine class is deprecated since version 4.3 and will be removed in 5.0; use \Twig\Environment 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 Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplatePathsCacheWarmer 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 Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinder class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

The Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface 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 Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.

The Symfony\Bundle\FrameworkBundle\Templating\TemplateReference 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 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

解决方案:

  1. composer.json 中删除 "symfony/templated"
  2. framework.yaml 中删除此内容:
    templating:
    engines:
    - twig
  3. 运行composer更新

这应该删除所有弃用警告。

如果您收到此错误

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\Templated\EngineInterface 更改为 Twig\Environment:

use Twig\Environment;

private $twig;

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

另请参阅https://github.com/symfony/symfony/issues/31645

关于php - Symfony 4.3 : User Deprecated: The Symfony\Bundle\TwigBundle\Loader\FilesystemLoader class is deprecated since version 4. 3 并将在 5.0 中删除...,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58380812/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com