Skip to content

[TwigComponent] Allow standalone usage with any PSR-11 container - #3602

Merged
Kocal merged 1 commit into
symfony:3.xfrom
guillaume-sainthillier:twig-ux-component-psr
Jun 11, 2026
Merged

Kocal merged 1 commit into
symfony:3.xfrom
guillaume-sainthillier:twig-ux-component-psr

Conversation

@guillaume-sainthillier

Copy link
Copy Markdown
Contributor
Q A
Bug fix? no
New feature? yes
Deprecations? no
Documentation? no
Issues -
License MIT

Allow TwigComponent's runtime to work without symfony/dependency-injection.

ComponentFactory and ComponentRuntime only ever call get()/has() on
their injected service locator. Both methods are defined by PSR-11
Psr\Container\ContainerInterface, which Symfony's ServiceLocator already
implements — so the injection points can be typehinted against the interface
instead of the concrete class.

This decouples the runtime classes from the DI component: they can now be
wired with any PSR-11 container, enabling standalone (non-Symfony) usage with
just Twig. symfony/dependency-injection moves to require-dev (still pulled
transitively via symfony/framework-bundle in a full Symfony app, and only
needed at runtime for the bundle's extension/compiler-pass classes).

// Standalone wiring, no symfony/dependency-injection required
$factory = new ComponentFactory(
    $templateFinder,
    $myPsr11Container, // any Psr\Container\ContainerInterface
    $propertyAccessor,
    $eventDispatcher,
    $config,
    $classMap,
    $twig,
);

@Kocal
Kocal force-pushed the twig-ux-component-psr branch from 3552508 to 8180244 Compare June 11, 2026 20:32
@Kocal Kocal changed the title [TwigComponent] make it compatible with psr [TwigComponent] Allow standalone usage with any PSR-11 container Jun 11, 2026
@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Jun 11, 2026
@Kocal

Kocal commented Jun 11, 2026

Copy link
Copy Markdown
Member

Thank you @guillaume-sainthillier.

@Kocal
Kocal merged commit 5a70caf into symfony:3.x Jun 11, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature New Feature Status: Reviewed Has been reviewed by a maintainer TwigComponent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants