Skip to content

[TwigBridge][DebugCommand] Attempted to call an undefined method named "getNamespaces" of class "Twig_Loader_Chain". #30426

@diepm

Description

@diepm

Symfony version(s) affected: 4.1 and 4.2 (have not tried with other versions).

Description

This happens when I use multiple Twig loaders and run ./bin/console debug:twig. The error message is

In DebugCommand.php line 249:

   Attempted to call an undefined method named "getNamespaces" of class "Twig_Loader_Chain".

How to reproduce

  • Start a new Symfony project composer create-project symfony/website-skeleton test
  • Add a new Twig loader to services.yaml, under services: section, as extra_twig_loader: { class: Twig\Loader\FilesystemLoader }
  • Run ./bin/console debug:twig

I might have been missing something when adding a new Twig loader, but for now, it's the error I get. Looking at DebugCommand.php code, the Twig loader instance for multiple Twig loaders is ChainLoader instead of FilesystemLoader. This ChainLoader doesn't have getNamespaces() method.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions