twig/string-extra
Twig extension integrating Symfony String, adding u, slug, singular, and plural filters for Unicode-aware text manipulation, URL-friendly slugs, and simple word inflection directly in your templates.
u, slug, singular, plural. These are the exact primitives needed for blog/CMS, catalog, and marketing pages without new service-layer endpoints.Str::slug() helpers, ad-hoc ucfirst/titlecase regex, and third-party slug libs with one MIT-licensed extension backed by the Symfony String component. Decision: buy (adopt) instead of maintain bespoke string utilities.u filter’s UnicodeString access is a prerequisite for i18n work (transliteration, grapheme-safe truncation, case mapping) that would otherwise require a separate vendor evaluation.laravel-twig) or (b) port the same Symfony String filters into Blade directives. That is a genuine roadmap fork worth a written decision record.Adopt when:
slug, singular, plural, and u in templates.{{ title|slug }} replaces a controller-side Str::slug() call and the plumbing to pass the slug through.Look elsewhere when:
Illuminate\Support\Str / Str::of() instead unless you are deliberately adopting Twig.slug column used for routing). Compute it in the domain layer once, not in a template at render time.For executives “This is a small, MIT-licensed Twig extension that gives our template layer native support for the string operations our content features depend on — SEO-friendly slugs, pluralized list headings, localized text casing, and Unicode-safe truncation. It removes the need to hand-roll and maintain these helpers, which reduces the surface area for bugs and speeds up content feature delivery. Its main constraint is scope: it only earns its place if we render with Twig. If we stay Blade-first, we should treat this as a benchmark and replicate the same filters via directives rather than adopt it directly. Low cost, low risk, and a clean build-vs-buy decision either way.”
For engineering
“twig/string-extra is a thin, well-scoped adapter that exposes Symfony String as Twig filters: u (returns a UnicodeString so you can chain methods), slug (AsciiSlugger), and singular / plural (Inflector). Value is in consistency: one canonical implementation of presentation-layer string logic instead of scattered Str::slug() calls and regex helpers.
Adoption guidance:
@slugify($title)) and treat this package as the reference implementation. That gets you the same semantics without an engine migration.symfony/string version aligns with the Laravel/Symfony versions already in composer.json; pin/conflict as needed. Test Unicode edge cases (Café au lait → cafe-au-lait) and empty inputs before rollout.Bottom line: adopt where Twig is already present; mirror the pattern via directives where it isn’t. Either way, formalize the rule that presentation strings are a template concern and identity/store strings are not.”
How can I help you explore Laravel packages today?