Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Twig Extension Proxy Bundle Laravel Package

markup/twig-extension-proxy-bundle

Symfony bundle that adds a Twig extension proxy, routing function, filter and test calls through one service so extensions can be decorated, lazy-loaded or overridden without touching your templates.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit — poor, and the mismatch is structural rather than cosmetic. markup/twig-extension-proxy-bundle is a Symfony bundle: it registers through Symfony's Bundle class, relies on the DependencyInjection component's compiler passes and service tagging to discover Twig\Extension\ExtensionInterface services, and substitutes lazy proxy objects into the Twig environment so an extension's constructor is deferred until one of its filters/functions/tests is actually invoked. Laravel sits on a different kernel: it borrows Symfony components (HttpFoundation, Routing, Console, VarDumper, ErrorHandler) but does not use symfony/dependency-injection, symfony/http-kernel, or the Bundle system. There is no bundles.php, no compiler-pass pipeline, and no autoconfiguration-by-interface. The package cannot be composer required into a Laravel app and function.

Twig is also not the default templating layer. Laravel ships Blade. Twig only enters the picture via a third-party bridge (historically rcrowe/twigbridge), which has its own extension registration path through a TwigExtension service provider contract — it does not read Symfony bundle configuration. So even in a Twig-on-Laravel stack, this bundle's registration mechanism has nothing to hook into. The underlying idea (proxy the extension so expensive constructors don't run on every request) transfers cleanly; the implementation does not.

Integration feasibility — feasible only as a source-level port, not as a dependency. The proxy logic itself is small and conceptually simple; a TPM should treat this as "read ~a few hundred lines, reimplement against Laravel's container" rather than "evaluate a package for adoption." A DeferrableProvider-style or bind()-with-closure approach in a TwigServiceProvider gets most of the benefit with no third-party surface area.

Technical risk — high on maintenance, low on supply chain, moderate on correctness.

  • Maintenance/abandonment: 0 stars, 0 dependents, single-org publisher, no downstream validation. Treat as unmaintained until proven otherwise; check last commit date, open issues, and branch activity before anything else.
  • Supply chain: negligible blast radius (nobody depends on it), but also zero peer review — the code has not been read by anyone outside the author.
  • Correctness risk: lazy proxies are subtle. A proxy that satisfies ExtensionInterface but forwards getFilters()/getFunctions() eagerly can invert the intended optimization; proxies that forward getName() incorrectly break Twig's extension registry on newer Twig versions where getName() was deprecated/removed (Twig 3.x). Version drift here is a live hazard.

Key questions for the requesting team:

  1. Is the target application actually Laravel, or is this a Symfony service mislabeled in the intake? Confirm before spending further effort.
  2. If Laravel: are we running Twig at all, and via which bridge and version?
  3. What is the measured problem — per-request container construction cost from heavy extensions? Do we have profiling data (Telescope, Blackfire, XHProf) showing extension instantiation in the hot path?
  4. Are the "heavy" extensions ours or third-party? If ours, fix the constructors instead of proxying them.
  5. Who owns the fork if we port it, and what is the review bar for adopting unreviewed code?

Integration Approach

Stack fit: do not adopt the package; harvest the pattern. The realistic decision tree:

  • Laravel + Blade (most likely): Not applicable. Close the ticket, or reframe it as "reduce Twig/Blade extension overhead" — which is moot for Blade, since Blade compiles to plain PHP and directives are registered as static strings, not instantiated objects.
  • Laravel + Twig via bridge: Port the proxy concept into a Laravel service provider registered through the bridge's extension contract. Wrap each expensive extension in a proxy whose getFilters()/getFunctions()/getTests() return closures that resolve the real extension from the container on first call.
  • Symfony application: Then this bundle is a legitimate candidate — but it still fails the adoption bar on 0 dependents and no maintenance signal. Vendor it, pin it, and own it.

Migration path. There is no in-place migration because there is no prior integration. The path is: (1) confirm the framework and templating layer; (2) if Laravel, snapshot the proxy classes from the repo at a pinned commit, vendor them under an internal namespace, and rewrite registration against Illuminate\Contracts\Container\Container; (3) add a regression test asserting that an unused extension's constructor is not called on a request that renders a template — this is the whole point of the change and the only meaningful acceptance criterion.

Compatibility. Check the bundle's composer.json for PHP and Symfony version constraints. Symfony's Bundle interface and ExtensionInterface have both changed across 5.x → 6.x → 7.x (return types, getName() removal). Any port must be re-targeted at the Twig version the bridge actually pulls in, and at PHP 8.x typing conventions. Also confirm the license travels with vendored code — MIT does, but keep the attribution header.

Sequencing.

  1. Framework/templating confirmation (hours).
  2. Profiling to quantify the problem — do not port code to solve an unmeasured cost (1–2 days).
  3. If the cost is real: vendor-and-port spike behind a feature flag, with the "constructor not called" test (2–3 days).
  4. Compare against the cheaper alternative: fix the offending extension constructors, or move their expensive dependencies behind container closures. This likely obviates the whole exercise.
  5. Only if 3 clearly beats 4, promote out of the flag.

Operational Impact

Maintenance. Adoption means permanent ownership. With 0 stars and 0 dependents there is no upstream community to absorb Twig/Symfony version churn, no security triage, and no expectation of a response to issues. Budget a fork-maintenance line item: roughly a few hours per Twig major/minor bump to re-verify the proxy contract, plus the initial review. If the port is done properly (a handful of internal classes), this is cheap and contained; if the bundle is vendored wholesale, you inherit Symfony DI assumptions that will rot.

Support. No vendor, no SLA, no documented upgrade path. Internal escalation is "whoever ported it." That is acceptable for a small internal utility with a named owner and unacceptable as a silent dependency buried in a service provider. Assign an explicit owner and record the pinned source commit in the repo.

Scaling. The performance argument is per-request CPU, not horizontal scale — it reduces work on every request by skipping unused extension construction. The win is real but bounded by how expensive those constructors are; for typical extensions (a few array literals) it is noise. If the constructors do I/O or hit the container for heavy services, the win compounds and the change is worth it. Do not sell this as a scalability improvement; sell it as a latency/CPU micro-optimization with a measurable baseline or not at all.

Failure modes to watch.

  • Silent no-op: the proxy registers but Twig never receives it, so behavior is unchanged and nobody notices the change did nothing. Caught only by the constructor-not-called test.
  • Eager leak: the proxy's own getFilters() calls $this->extension->getFilters(), defeating the laziness. Easy to write, hard to spot in review.
  • Masked circular dependencies: lazy resolution can hide a container cycle that eager instantiation would have surfaced at boot, pushing the failure from deploy-time to first-render-time in production.
  • Interface drift: a Twig upgrade adds a method to ExtensionInterface; the proxy doesn't implement it; templates using that construct fail at render. Mitigate with a contract test against the pinned Twig version in CI.
  • Container caching differences: Symfony compiles the container and dumps proxies; Laravel's container is rebuilt per process with a compiled services.php for bindings only. Any behavior that depended on compile-time proxy generation will not reproduce; verify in the Octane/queue/CLI contexts separately, since long-lived workers cache resolved instances differently than FPM.

Ramp-up. Low for anyone comfortable with Laravel's container; moderate if the team needs to read Symfony DI idioms (compiler passes, service tags, autoconfiguration) to understand the source. The ported code itself is small enough for one engineer to own end-to-end.

Recommendation framing for the review: reject as a dependency; retain as a reference implementation if and only if profiling shows extension construction is a real per-request cost. The default disposition for a 0-star, 0-dependent Symfony bundle in a Laravel intake is "not applicable — confirm framework, then solve natively."

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource