symfony/intl
Symfony Intl component provides access to ICU localization data: locales, languages, countries, scripts, currencies, time zones and more. Includes optional zlib-based data compression via the provided compress script for smaller distributions.
AppServiceProvider or package-specific bindings. Works alongside Laravel’s trans() helper for hybrid localization (e.g., display country names in user-preferred languages while leveraging Symfony’s authoritative data).Form Component (e.g., CurrencyType with active_at/not_active_at filters for compliance-heavy features).Validator for ISO-compliant country/currency checks (e.g., rule('country')->in(Intl\Countries::getAlpha2Codes())).@currencySymbol('EUR')) can wrap Symfony’s methods for templating consistency.intl extension), making it ideal for API-first Laravel apps or microservices requiring lightweight localization data.intl extension is unavailable, the package provides a pure-PHP implementation (with minor performance trade-offs for advanced ICU features).composer update symfony/intl.php vendor/symfony/intl/Resources/bin/compress (reduces size by ~50%).TimeZone) if not needed.^7.4.0) in composer.json.EmojiTransliterator) require the intl extension. Mitigation:
README.intl extension enabled? If not, will you need advanced ICU features (e.g., collation, pluralization)?XK region code) may require manual intervention.en_US, fr_FR, ja_JP)? Edge cases (e.g., deprecated currencies) may slip through without comprehensive testing.AppServiceProvider:
$this->app->singleton(Intl\Countries::class, fn() => new Intl\Countries());
Blade::directive('currencySymbol', fn($expression) => "<?php echo Symfony\Component\Intl\Currencies::getSymbol($expression); ?>");
Usage: @currencySymbol('EUR') → €.CurrencyType with Symfony’s new filters:
->add('currency', CurrencyType::class, [
'active_at' => '2023-01-01', // Only show active currencies
]);
Validator::extend('valid_country', fn($attribute, $value, $parameters, $validator) =>
in_array(strtoupper($value), Intl\Countries::getAlpha2Codes())
);
return response()->json([
'countries' => Intl\Countries::getNames(app()->getLocale()),
]);
$countries = Intl\Countries::getNames('en');
// Export to CSV/Excel
XK region code, stale currency data).Intl\Countries::getNames()).EmojiTransliterator if intl extension is available).countries.json for Intl\Countries).country_code → ISO 3166-1 alpha-2).symfony/intl:^7.4 or ^8.0.symfony/intl:^6.4.intl extension: Pure-PHP fallback works for basic features.intl extension enabled: Unlocks full ICU functionality (e.g., EmojiTransliterator, advanced collation).composer.json:
"require": {
"symfony/intl": "^7.4"
}
composer update symfony/intl.php vendor/symfony/intl/Resources/bin/compress
AppServiceProvider.en_US, fr_FR, ja_JP).XK, deprecated currencies like TRL).intl extension for performance-critical features (e.g., collation).How can I help you explore Laravel packages today?