Download the PHP package padmission/number-no-intl without Composer
On this page you can find all versions of the php package padmission/number-no-intl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download padmission/number-no-intl
More information about padmission/number-no-intl
Files in padmission/number-no-intl
Package number-no-intl
Short Description A Laravel package that automatically replaces the default Laravel Number class with a version that doesn't require the intl extension.
License MIT
Homepage https://github.com/padmission/number-no-intl
Informations about the package number-no-intl
Laravel Number Without Intl Extension
A Laravel package that automatically replaces the default Laravel Number class with a version that doesn't require the PHP intl extension. This is particularly useful for environments where the intl extension cannot be installed or is unavailable.
Important Note
This package only fully supports the English ('en') locale. When using other locales, the formatting will still work, but text-based methods like spell()
and spellOrdinal()
will fall back to the English implementation or basic number formatting. This is a limitation of the implementation without the intl extension.
Features
- Zero Configuration: Once installed, automatically replaces Laravel's Number class when the intl extension is not available
- Fully Compatible: Implements all the methods from Laravel's original Number class
- Smart Detection: Only activates when needed (when intl extension is not available)
- Symfony Polyfill: Uses the Symfony polyfill for intl-icu to provide compatibility
- English-Only: Full functionality is available in the English locale, with limited support for other locales
Installation
You can install the package via composer:
That's it! No additional configuration is needed. The package will automatically detect if the intl extension is missing and replace Laravel's Number class accordingly.
Usage
Use Laravel's Number class as you normally would. The package will transparently replace it if the intl extension is not available:
All other methods from Laravel's Number class are also available:
spell()
: Spell out a number in words (e.g., "one hundred and twenty-three") - English onlyordinal()
: Convert a number to its ordinal form (e.g., 1st, 2nd, 3rd) - English onlyspellOrdinal()
: Spell out a number in ordinal form (e.g., "first", "second", "third") - English onlyfileSize()
: Convert bytes to a human-readable file sizeclamp()
: Clamp a number between min and max valuespairs()
: Split a number into pairs of min/max valuestrim()
: Remove trailing zeros from a numberwithLocale()
: Execute a callback with a specific localewithCurrency()
: Execute a callback with a specific currencyuseLocale()
: Set the default localeuseCurrency()
: Set the default currencydefaultLocale()
: Get the current default localedefaultCurrency()
: Get the current default currency
Locale Support Limitations
While the package allows you to set different locales using useLocale()
or withLocale()
, be aware of these limitations:
- Text-based methods (
spell()
,ordinal()
,spellOrdinal()
) only fully work in English - For non-English locales, text-based methods will either:
- Fall back to the English implementation
- Or return basic formatted numbers instead of text
- Basic formatting functions (
format()
,currency()
,percentage()
, etc.) work for all locales, but use standard English number formatting conventions (comma as thousands separator, period as decimal separator)
If you need full multi-language support, consider:
- Installing the PHP intl extension if possible
- Or implementing language-specific formatters for your required languages
Configuration
While the package works out of the box with zero configuration, you can publish the configuration file to customize its behavior:
This will create a config/number-no-intl.php
file with the following options:
How It Works
The package uses the following approach:
- When your application boots, it checks if the intl extension is installed
- If intl is available, by default the package does nothing and allows Laravel to use its built-in Number class
- If intl is not available, the package automatically binds a polyfill implementation that uses the Symfony polyfill for intl-icu
This ensures that your application works seamlessly across environments, regardless of whether the intl extension is installed or not.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Kevin McKee
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of number-no-intl with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0||^11.0||^12.0
symfony/polyfill-intl-icu Version ^1.27