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

symfony/polyfill-intl-icu

Fallback implementations for key PHP Intl/ICU features when the intl extension is missing. Provides en-locale support for intl error helpers plus Collator, NumberFormatter, Locale, and IntlDateFormatter, enabling basic internationalization without ext-intl.

View on GitHub
Deep Wiki
Context7

Getting Started

Install via Composer (automatically pulled in as a dependency when using Laravel or Symfony components); no manual configuration needed. Start using it immediately by writing code that relies on NumberFormatter, Collator, or Locale — the polyfill auto-registers via Composer’s autoload. Verify activation by calling class_exists('NumberFormatter') or function_exists('intl_is_failure'). Your first real-world use case: formatting currencies or numbers consistently across environments where ext-intl is absent — e.g., local development on minimal Docker images or shared hosting.

Implementation Patterns

  • Write Portable i18n Code: Use ICU classes natively (new IntlDateFormatter(...), new Collator(...)) without conditional checks. The polyfill seamlessly patches missing functionality.
  • Error Handling Consistency: Leverage ICU error APIs (intl_get_error_code(), intl_get_error_message()) to catch subtle formatting failures — especially useful when validating user-provided locale strings (e.g., new NumberFormatter($userLocale, ...)).
  • Test Coverage in Restricted Environments: Run unit/integration tests in CI pipelines that omit ext-intl (e.g., GitHub Actions with minimal PHP builds), ensuring your i18n logic remains robust regardless of server configuration.

Gotchas and Tips

  • English-Only Reality: The polyfill only supports the en locale — even if you request fr_FR, outputs will default to English formatting (e.g., dates as MM/dd/yyyy, numbers as 1,234.56). Add runtime guards (e.g., if (Locale::getDefault() !== 'en') { /* warn or fallback */ }) in early development.
  • Silent Degradation: No exceptions are thrown for unsupported locales or features — incorrect formatting may occur without warning. Log Locale::getDefault() in debug mode during testing to catch misconfigurations.
  • Performance Tradeoffs: ICU object instantiation (especially Collator and IntlDateFormatter) is 3–5× slower than native ext-intl. For high-volume operations (e.g., bulk currency formatting), precompute or cache results.
  • Never Use for Non-English Production: Avoid deploying to multilingual apps without ext-intl — formatting, collation, and calendar rules for other locales will be incorrect. This polyfill is strictly a fallback, not a production i18n solution.
  • Autoloader Precedence Works in Your Favor: If ext-intl is installed, it always overrides the polyfill — so you can safely include it project-wide without conditional logic.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport