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
String Extra

String Extra Laravel Package

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.

View on GitHub
Deep Wiki
Context7

A Twig extension for Symfony String

Frequently asked questions about String Extra
What is twig/string-extra used for?
It is a Twig extension that integrates Symfony String into templates. It registers the u, slug, singular, and plural filters so you can do Unicode-aware string handling, URL slugs, and simple inflection in Twig. It is a presentation-layer helper, not a Laravel business-logic package.
How do I install twig/string-extra in a Laravel app?
Install it with Composer using composer require twig/string-extra symfony/string. Then register Twig\Extra\String\StringExtension in your Twig environment configuration. This only makes sense if your Laravel app actually renders Twig through a bridge or a Symfony-style Twig service.
Does twig/string-extra work with Laravel Blade?
No, not as-is. The package provides Twig filters, so Blade templates cannot call them directly. Blade-first Laravel apps should use Laravel's Str::slug, Str::plural, and Str::of helpers, or write a small custom directive that wraps Symfony\Component\String\UnicodeString.
Which Laravel versions are compatible with twig/string-extra?
The package does not target Laravel versions directly; it is a Twig extension. Compatibility depends on your Twig integration and the symfony/string constraint that Laravel already pins. Run composer why-not symfony/string before adding it to avoid forcing a lockfile-wide Symfony upgrade.
What filters does twig/string-extra add?
It adds four filters: u wraps text in a Symfony UnicodeString, slug wraps AsciiSlugger::slug, and singular and plural wrap the Inflector's singularize and pluralize methods. These are intended for template-level text manipulation, not domain logic.
Do I need symfony/string installed separately?
Yes. twig/string-extra is a thin wrapper around Symfony String components, so symfony/string must be available. In many Laravel projects it is already present transitively, but you should verify the installed constraint before relying on it.
How do I register the StringExtension in Twig?
Add Twig\Extra\String\StringExtension to the extensions list of your Twig environment. In a Laravel Twig bridge, this is usually done in the Twig configuration or service provider that builds the environment. There is no package-specific config, middleware, or Laravel service provider to publish.
Can twig/string-extra handle Unicode and multilingual text?
The u filter gives you Symfony UnicodeString methods, and slug uses AsciiSlugger for transliteration-friendly URLs. The singular and plural filters use Symfony's Inflector and are best treated as simple English-oriented inflection helpers. Test locale-specific and non-English cases in your templates before depending on them.
Is twig/string-extra safe to use in production?
It is MIT-licensed, small, and maintained in step with Twig releases, with behavior inherited from Symfony String. The main risks are version coupling to symfony/string and thin community adoption around the Twig wrapper itself. Add template-level regression tests for Unicode, slugs, inflection, and empty strings.
What are alternatives to twig/string-extra in Laravel?
For Blade, use Laravel's native Str::slug, Str::plural, and Str::of methods. For Twig, you can register Symfony String directly in a custom extension or call UnicodeString from a Twig function. If you only need URL slugs, Laravel's Str::slug is usually the simpler choice.
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.
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel