Weave Code
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
Polyfill Intl Grapheme

Polyfill Intl Grapheme Laravel Package

symfony/polyfill-intl-grapheme

Native PHP polyfill for Intl Grapheme functions when ext-intl isn’t available. Works with UTF-8 strings and provides grapheme-aware length, substring, splitting, extraction, and case-sensitive/insensitive position and search functions.

View on GitHub
Deep Wiki
Context7

Symfony polyfill for intl's grapheme_* functions

Frequently asked questions about Polyfill Intl Grapheme
How do I install this polyfill in a Laravel project?
Run `composer require symfony/polyfill-intl-grapheme:^1.38` in your project directory. The package is autoloaded via Composer, so no additional configuration is needed unless you’re extending Laravel’s Str helper for custom grapheme methods.
Does this work with Laravel’s Str helper for RTL text (e.g., Arabic, Hebrew)?
Yes, this polyfill enables grapheme-aware operations like reversing RTL text correctly. You can extend Laravel’s Str helper to add methods like `Str::graphemeReverse()` for seamless integration with Laravel’s existing string utilities.
What Laravel versions and PHP versions does this polyfill support?
This polyfill works with Laravel 8+ and PHP 7.4+. However, the `grapheme_strrev()` function requires PHP 8.6+. For older PHP versions, the polyfill provides backward compatibility for other grapheme functions but lacks `grapheme_strrev()`.
Will this break my existing Laravel application if I install it?
No, this is a drop-in polyfill that only activates when the `ext-intl` extension is missing or when PHP lacks native grapheme support. It won’t interfere with existing functionality unless you explicitly use its grapheme functions.
How does this polyfill handle emojis and combining characters (e.g., flags, skin tones)?
The polyfill correctly processes grapheme clusters, including emojis and combining characters (e.g., `👨‍👩‍👧‍👦`). Functions like `grapheme_strlen()` and `grapheme_substr()` ensure these are treated as single units, preventing incorrect splitting or reversal.
Is there a performance impact compared to using the native `ext-intl` extension?
Yes, the polyfill introduces a ~5–10% overhead compared to native `ext-intl` functions. For high-throughput operations (e.g., bulk text processing or real-time search), this may be noticeable, but it’s negligible for most Laravel applications handling RTL or Unicode text.
Can I use this polyfill alongside Laravel’s localization (L10n) features?
Absolutely. This polyfill complements Laravel’s localization by ensuring grapheme-aware string operations (e.g., reversing, splitting, or searching RTL text) work correctly. It’s particularly useful for form validation, search queries, and user-generated content in multilingual apps.
What if my Laravel app uses PHP 8.1 or 8.2 and needs `grapheme_strrev()`?
The polyfill does not support `grapheme_strrev()` in PHP <8.6. For older PHP versions, you’ll need either the `ext-intl` extension or a custom solution. Check Symfony’s [upgrade guide](https://github.com/symfony/polyfill/blob/main/UPGRADE.md) for alternatives.
Does this polyfill support full Unicode normalization (e.g., NFKC, NFD)?
No, this polyfill focuses solely on grapheme cluster operations. For full Unicode normalization, you’ll need additional polyfills like `symfony/polyfill-intl-normalizer` or the `ext-intl` extension.
Are there alternatives to this polyfill for Laravel?
If you’re on PHP 8.6+, the native `grapheme_strrev()` function is the best alternative. For older PHP versions, you could use `ext-intl` or a custom implementation, but this polyfill is the most robust and widely tested solution for grapheme-aware operations in Laravel.
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony