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
Lara Asp Formatter

Lara Asp Formatter Laravel Package

lastdragon-ru/lara-asp-formatter

View on GitHub
Deep Wiki
Context7

Provides a customizable wrapper around Intl formatters to use it inside Laravel application. And also allows defining your own formats.

Frequently asked questions about Lara Asp Formatter
How do I install `lastdragon-ru/lara-asp-formatter` in a Laravel project?
Run `composer require lastdragon-ru/lara-asp-formatter` in your project root. The package integrates seamlessly with Laravel’s service container and requires PHP 8.0+ and Laravel 8.0+. Ensure the `intl` extension is enabled in your PHP environment.
Does this package support Laravel 11 or 13?
Yes, it supports Laravel 11 (up to 11.0.8) and Laravel 13 (via HEAD for 13.10.0). Check the [requirements table](https://github.com/LastDragon-ru/lara-asp-formatter) for exact version constraints. For Laravel 13, use the latest `dev-HHEAD` branch.
Can I define custom formats beyond the built-in ones?
Absolutely. The package allows defining custom formats in the `config/lara-asp-formatter.php` file after publishing it with `php artisan vendor:publish --provider=LastDragon_ru\LaraASP\Formatter\PackageProvider --tag=config`. This is useful for domain-specific needs like scientific notation or legacy formats.
What happens if the `intl` PHP extension is missing?
The package will throw a runtime error if `intl` is disabled. To avoid this, add `ext-intl` as a dev requirement in your `composer.json` or ensure your hosting environment (e.g., shared servers) has it enabled. Test locally with `php -m | grep intl` before deployment.
How do I handle dynamic format changes at runtime?
The formatter caches resolved formats for performance. To apply runtime changes, clone the formatter instance using `clone $formatter` to reset the internal cache. This is documented in the [usage examples](https://github.com/LastDragon-ru/lara-asp-formatter).
Is there built-in validation for format strings?
No, the package does not validate format strings, which could lead to runtime errors with malformed patterns. Validate inputs manually or extend the formatter class to add validation logic before passing strings to `NumberFormatter` or `DateFormatter`.
Can I use this package for currency formatting in an e-commerce app?
Yes, it’s ideal for e-commerce. Use built-in formats like `'currency'` or define custom ones in the config. For example, configure `'default_currency'` and `'currency_symbol'` in `config/lara-asp-formatter.php` to standardize prices across locales.
What are the alternatives to this package?
Consider Laravel’s built-in `NumberFormatter` or `IntlDateFormatter` for simple use cases. For currency-specific needs, explore `moneyphp/money` or `league/iso3166`. If you need a more feature-rich wrapper, `symfony/intl` offers additional utilities like locale detection.
How do I test edge cases like right-to-left (RTL) languages?
Test with locales like `ar` (Arabic) or `he` (Hebrew) using the formatter’s `format()` method. Mock the `Intl` extension in unit tests or use PHPUnit’s `setLocale()` to simulate RTL environments. Ensure your CI/CD pipeline includes these locales.
Will this package work with shared hosting that doesn’t allow PHP extensions?
No, the package requires the `intl` extension, which may not be available on shared hosting. Contact your host to enable it or consider alternatives like `symfony/intl` if extension installation isn’t possible. Always verify `intl` support before deploying.
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky