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 Laravel Package

symfony/string

Symfony String offers an object-oriented API for working with text, handling bytes, UTF-8 code points, and grapheme clusters in a unified way. It provides convenient, encoding-safe methods for slicing, comparing, searching, and manipulating strings.

View on GitHub
Deep Wiki
Context7

Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way

Frequently asked questions about String
How do I install symfony/string in a Laravel app?
Run composer require symfony/string. There is no service provider to register and no configuration file to publish because the package is a plain library. In many Laravel apps it is already installed transitively through symfony/translation, so check composer show symfony/string before adding it explicitly.
Laravel already has Str and Stringable, so why use symfony/string?
Laravel's Str and Stringable cover common formatting and fluent helpers, but symfony/string fills specific gaps: display width, grapheme-cluster-safe truncation, locale-aware slugging with AsciiSlugger, inflectors, and explicit byte, code-point, and grapheme types. Use it when those capabilities matter, not as a blanket replacement for Str everywhere.
What is the difference between ByteString, CodePointString, and UnicodeString?
ByteString operates on raw bytes, CodePointString on UTF-8 code points, and UnicodeString on user-perceived grapheme clusters. Choosing the right type makes your intent explicit and prevents bugs such as cutting an emoji or combining mark mid-cluster. All three share the AbstractString API.
Which PHP and Laravel versions does symfony/string support?
The package itself is framework-agnostic and works in any Laravel version that can install it via Composer. The v8.x line requires PHP 8.4 or newer, while v7.4 is the line typically compatible with older Laravel PHP floors. Check your app's resolved Symfony version with composer why symfony/string.
Does symfony/string require ext-intl?
It is not strictly required, but locale-aware slugging, localeTitle(), transliteration, and Unicode normalization behave differently with and without intl/ICU. Fallback paths have had bugs, and ICU version drift between dev, CI, and production can cause inconsistent output. Test those features in an environment that matches production.
How do I truncate strings with emoji or grapheme clusters safely?
Use UnicodeString with the truncate() method and an explicit TruncateMode to avoid splitting emoji, skin tones, or combining marks. This is one of the areas where Illuminate\Support\Str is weaker, especially for UI text, tables, and exports. Add tests with real emoji and CJK samples.
Can I use symfony/string for locale-aware slugs in Laravel?
Yes. AsciiSlugger supports a settable locale for transliteration beyond Laravel's ASCII slugging. You need to install and configure it yourself; there is no Laravel service provider or config publish step. Verify behavior with ext-intl enabled and disabled if your environments differ.
Will symfony/string conflict with symfony/translation's version constraint?
symfony/string is often already present through symfony/translation, which may pin an older major version. Declaring ^8.0 when the app resolves 7.4.x produces a Composer conflict, which is better than silent skew but still requires a cross-team version decision. Run composer why symfony/string before designing around a specific API.
Is symfony/string safe for production, and what are the risks?
The dependency itself is low risk: MIT, Composer-only, with no container or config coupling. The real risks are version skew, ext-intl/ICU differences, and behavioral changes in edge semantics such as width() and out-of-range offsets. Pin versions, test edge cases, and review changelogs when upgrading.
How do I test code that uses symfony/string?
Write unit tests around the specific behaviors you rely on, including emoji truncation, width calculation, slugging with and without intl, and boundary offsets. Run CI with the same PHP, Symfony String, and ICU versions as production where possible. Because the package has no Laravel integration layer, ordinary PHPUnit tests are sufficient.
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.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core