mapado/twig-extensions-bundle
A Symfony bundle that bundles useful Twig extensions from the Mapado Twig Extensions library into your application, adding handy filters and functions to templates with minimal setup and configuration.
Architecture fit — mismatch against the stated stack. The package is a Symfony bundle, not a Laravel package. Its entry point is a Bundle subclass registered in the kernel and wired through Symfony's DependencyInjection container; Laravel has no equivalent concept, so the bundle wrapper cannot be booted natively. The only genuinely portable artifact is the underlying Twig extension class implementing Twig\Extension\ExtensionInterface, which is framework-agnostic and can be registered in any Twig environment. The practical consequence for a TPM: the "package" as shipped is ~90% Symfony plumbing and ~10% functional code, and that functional code is a thin wrapper over PHP's native parse_url().
Functional scope. Effectively a single Twig filter/function exposing parse_url — URL decomposition (scheme, host, path, query, fragment) inside templates. There is no broader toolkit. The description ("parse_url for now") is accurate and the entire extension is readable in minutes.
Integration feasibility — feasible but disproportionate. Absolute engineering effort is low (extract one class or reimplement in ~15–20 lines). But adopting it as a dependency in a Blade-first Laravel app would require standing up a third-party Twig bridge — a large architectural commitment justified only for one filter. In a Laravel app that already runs Twig (e.g. via rcrowe/twigbridge), the extension class can be registered directly through the bridge's extension list, bypassing the bundle entirely.
Technical risk — high for a trivial payload.
parse_url wrapper.getName() removal, base-class changes). Compatibility is unverified from available metadata.Key questions for the team.
parse_url-in-templates worth a dependency when a small custom Twig extension — or a Blade directive / view composer — delivers the same result with zero external risk?Stack fit. Laravel + Blade (the default): no fit — do not adopt. Laravel + an existing Twig bridge: conditional fit, and even then register the extension class directly rather than attempting to boot the Symfony bundle.
Recommended path — treat the repo as reference source, not a dependency. Two viable options:
app/Twig/Extensions/ParseUrlExtension.php under our namespace and license header. Preserves behavior, removes the unlicensed dependency and the bundle wrapper.parse_url(). The functional delta versus extraction is negligible and this is the lower-risk default.Compatibility checks before any code lands. Inspect the package composer.json for PHP, Twig, and Symfony constraints. Confirm whether the extension registers as a filter, a function, or both so template call sites are preserved on reimplementation. Verify behavior on the parse_url() edge cases we care about — malformed input returns false, and relative URLs return no host.
Sequencing.
false/null handling on malformed input).app/Twig/Extensions/ with our own license header.ServiceProvider; add a unit test covering valid URL, relative URL, and malformed input.mapado/twig-extensions-bundle to production.Where this capability belongs. For anything beyond presentation — building redirects, comparing URLs, deduplicating sitemap entries, parsing query strings into key/value maps — do the parsing in a service or controller and hand the template a prepared value. Templates are the wrong place to branch on URL structure. Templates should consume a ready-made value ($urlParts, $host) rather than embed parse_url semantics.
Maintenance. Effectively zero upstream maintenance — the team inherits full ownership immediately. If we vendor-extract, we own Twig-major upgrade work on code we did not write; reimplementing collapses that to our own code under our own upgrade cadence. Either way, budget a small recurring cost for Twig signature changes and treat it as part of the internal Twig helpers surface.
Support. No community, no dependents, no maintainer responsiveness signal. There is no escalation path for a defect — we are the maintainers. This is tolerable only because the code is trivially auditable, which is precisely why extract/reimplement is preferred over dependency.
Scaling. Negligible. parse_url is a native PHP call with no I/O and no allocation pressure; rendering overhead is bounded by template usage frequency, not by the extension. No infrastructure implications, no caching considerations.
Failure modes to instrument.
parse_url returns false on severely malformed input; the extension's handling must be verified so templates degrade gracefully rather than emitting warnings.parse_url() returns query as a raw string. Teams expecting a key/value map will hand-roll string splitting in Twig, which is fragile. Document that a separate helper is required.Ramp-up. Technical ramp is near-zero — an engineer can read the entire package in minutes. Process overhead (legal, security, SCA review) dominates and is disproportionate to the value delivered. TPM recommendation: do not adopt as a dependency. Extract or reimplement the single parse_url extension into the internal Twig helpers surface, and revisit only if upstream matures to a clear license, a tagged release cadence, and confirmed Twig 3 support.
How can I help you explore Laravel packages today?