symfony/polyfill-intl-normalizer
Fallback implementation of PHP Intl’s Normalizer class when the intl extension isn’t available. Part of Symfony’s Polyfill suite, providing compatible Unicode normalization support across environments under the MIT license.
normalizer_get_raw_decomposition() (via Normalizer::getRawDecomposition()) expands the polyfill’s utility for Unicode decomposition/analysis, critical for:
symfony/intl or rubix/ml).symfony/intl), reducing fragmentation in Laravel applications using multiple Symfony components.Normalizer usage (e.g., FORM_C, FORM_D) remains unaffected. The new method is additive.composer require symfony/polyfill-intl-normalizer:^1.38.0 auto-updates the polyfill.Str::ascii(), Str::slug(), and custom helpers using Normalizer.$decomposed = Normalizer::getRawDecomposition('🇺🇸'); // Returns decomposed grapheme clusters.
getRawDecomposition() may introduce additional CPU/memory usage for large texts (e.g., processing 10K+ characters). Benchmark with:
$start = microtime(true);
Normalizer::getRawDecomposition(str_repeat('é', 10000));
echo microtime(true) - $start; // Compare against native `intl`.
mbstring Dependency: Silent failure if disabled (mitigate with runtime checks as before).intl:
# GitHub Actions example
jobs:
test:
strategy:
matrix:
php-ext-intl: [0, 1]
Use Case Justification:
Performance Tradeoffs:
Maintenance and Governance:
1.38.0 → 1.39.0)?
composer update (risk: potential BC breaks in minor releases)?^1.38 for stability?intl? If so:
intl via Docker/Kubernetes constraints.Alternative Solutions:
voku/portable-ascii, symfony/intl) provide decomposition without polyfill bloat?preg_replace() or Str::ascii().Laravel-Specific Considerations:
Validator::extend('decomposed_unicode', function ($attribute, $value) {
return Normalizer::getRawDecomposition($value) === $value;
});
App::setLocale())? Decomposition may interact with locale-specific rules.AppServiceProvider or BootstrapServiceProvider.symfony/polyfill-ctype, symfony/polyfill-mbstring).grep -r "Normalizer::" app/ tests/ | grep -v "normalize\|isNormalized"
intl disabled:
RUN docker-php-ext-disable intl
composer.json:
"require": {
"symfony/polyfill-intl-normalizer": "^1.38.0"
}
composer update symfony/polyfill-intl-normalizer --with-dependencies.Normalizer usage.// Example: Decompose emoji or accented characters
$decomposed = Normalizer::getRawDecomposition('Café 🇺🇸');
dd($decomposed);
intl (if available) for edge cases.$decomposed = cache()->remember("decomposed:{$string}", now()->addHours(1), fn() =>
Normalizer::getRawDecomposition($string)
);
getRawDecomposition().How can I help you explore Laravel packages today?