Symfony 4.3:用户已弃用:Symfony\Bundle\TwigBundle\Loader\FilesystemLoader class 自 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 …
升级到 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
解决方案:
- 从
composer.json
中删除 "symfony/templating"
- 从
framework.yaml
中删除:
templating:
engines:
- twig
- 运行
composer update
这应该会删除所有弃用警告。
如果您遇到此错误
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
:
use Twig\Environment;
private $twig;
public function __construct(Environment $twig)
{
$this->twig = $twig;
}
将 config/packages/framework.yaml: templating
替换为 fragments
:
来源:https://symfony.com/blog/new-in-symfony-4-3-deprecated-the-templating-component-integration
升级到 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
解决方案:
- 从
composer.json
中删除 - 从
framework.yaml
中删除:templating: engines: - twig
- 运行
composer update
"symfony/templating"
这应该会删除所有弃用警告。
如果您遇到此错误
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
:
use Twig\Environment;
private $twig;
public function __construct(Environment $twig)
{
$this->twig = $twig;
}
将 config/packages/framework.yaml: templating
替换为 fragments
:
来源:https://symfony.com/blog/new-in-symfony-4-3-deprecated-the-templating-component-integration