- What is symfony/polyfill-intl-normalizer used for in Laravel?
- It provides a fallback implementation of PHP's Normalizer class and related normalization functions when the intl extension is not installed. In Laravel applications it lets code that relies on Unicode normalization run consistently across servers, including multilingual content, search indexing, and validation. It is framework-agnostic and does not add Laravel-specific APIs.
- How do I install symfony/polyfill-intl-normalizer in a Laravel project?
- Install it with Composer by running composer require symfony/polyfill-intl-normalizer. Composer will update composer.json and composer.lock, and the polyfill loads automatically through Composer autoload files. You do not need to register a service provider or publish configuration.
- Does symfony/polyfill-intl-normalizer require the PHP intl extension?
- No. Its main purpose is to supply Normalizer when the intl extension is unavailable, so applications can normalize Unicode text without enabling intl. If intl is installed, PHP's native implementation is used and the polyfill steps aside. You should still ensure the rest of your Laravel stack meets its normal PHP extension requirements.
- Will it work with Laravel's Str::slug and Str::ascii helpers?
- The package makes the Normalizer class available, so any Laravel code or third-party package that calls Normalizer::normalize or related methods can work without intl. Laravel's Str::slug and Str::ascii helpers have their own dependencies and behavior, so test your specific use cases rather than assuming the polyfill changes those helpers. It is most useful for custom text processing around those helpers.
- Which Laravel and PHP versions are supported by symfony/polyfill-intl-normalizer?
- The polyfill is framework-agnostic and works with Laravel versions whose Composer setup can resolve the package's PHP requirement. Check the package's composer.json for the exact PHP version constraint for the release you install. It does not impose a Laravel version constraint beyond normal Composer dependency resolution.
- Does the polyfill override PHP's native Normalizer when intl is installed?
- No. Symfony polyfills are designed to provide classes and functions only when the native implementation is missing, so the intl extension takes precedence. This keeps behavior consistent with native intl on servers that have it enabled. You can still install the package as a safety net for environments without intl.
- What is normalizer_get_raw_decomposition and when should I use it?
- It provides raw Unicode decomposition data for a character or sequence, exposed through the normalizer_get_raw_decomposition function and the corresponding Normalizer method where available. Use it for debugging normalization behavior, auditing legacy text, or building custom normalization rules rather than simple NFC or NFD normalization. Because it can be slower and more complex than basic normalization, reserve it for targeted tasks and test with real multilingual data.
- Is symfony/polyfill-intl-normalizer fast enough for production Laravel apps?
- For typical request-level normalization of short strings it is generally fine, but native intl is faster, especially for high-volume batch processing or search-as-you-type workloads. Benchmark your actual use case with production-like data and cache decomposition results if you call expensive normalization repeatedly. If performance is critical, enable ext-intl and keep the polyfill only as a fallback.
- Do I need to configure anything after installing the polyfill?
- No Laravel configuration is required. The polyfill is loaded through Composer autoloading and defines the missing Normalizer functionality automatically. You may want to add a runtime check or deployment check for required extensions such as mbstring if your application depends on them.
- How should I test Unicode normalization in a Laravel application using this polyfill?
- Write PHPUnit tests with representative strings such as precomposed and decomposed accents, emoji sequences, and mixed-script text, then assert Normalizer::normalize and Normalizer::isNormalized results. Run the suite in an environment without intl to exercise the polyfill path, and compare against native intl where possible. Include tests for your actual Laravel validation, search, and storage flows.