8000 Should Twig require "router" and "router.request_context" services? · Issue #11466 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Should Twig require "router" and "router.request_context" services? #11466
Closed
@Warbo

Description

@Warbo

Zawinski's Law has lead me to send emails from my Symfony-based CLI application. These emails use Twig templates, so naturally I used TwigBundle.

When I tried this I hit a bunch of errors, since Twig refused to load without a "router" and "router.request_context" service. As far as I'm aware, routing is only needed for directing URLs to Controllers, so is completely unnecessary in a CLI app.

I haven't just had to add useless Symfony\Component\Routing\Router and Symfony\Component\Routing\RequestContext definitions to my services.yml, I've also had to define a Loader for the Router to use. Since I have no routes, I've used Symfony\Component\Routing\Loader\ClosureLoader, since at least that won't access the disk.

I'd rather not have to define these extra services. They clutter the configuration, require comments telling future maintainers why there's HTTP request handling machinery in a CLI app, they add extra dependencies/coupling and make the bootstrap more brittle.

Could they be removed as dependencies and loaded as needed please?

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

      0