Download the PHP package rnr1721/currency-service without Composer
On this page you can find all versions of the php package rnr1721/currency-service. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rnr1721/currency-service
More information about rnr1721/currency-service
Files in rnr1721/currency-service
Package currency-service
Short Description Laravel Currency Service with currency library, formatting and conversion
License MIT
Homepage https://github.com/rnr1721/currency-service
Informations about the package currency-service
Laravel Currency Service
Looking for a powerful and easy-to-use currency management tool for your Laravel application? Our Laravel Currency Service offers everything you need to manage currencies, handle conversions, track exchange rates, and store historical data — all in one seamless package.
Features
- Currency conversion with configurable precision and rounding modes
- Customizable currency formatting (position, separators, decimals)
- Exchange rate management with historical tracking
- Multiple rate providers support (includes TestRateProvider and OpenExchangeRates)
- Advanced caching system
- Historical rates analysis
- SOLID architecture principles
- Comprehensive test coverage
- Full Laravel integration
Requirements
- PHP 8.1 or higher
- Laravel 10.0 or higher
- Composer
Installation
Configuration (If you want to make automatic rates synchronization etc)
The configuration file will be published to Config/currency.php:
Currency Management
Initial Setup
- First, create your base currencies. At minimum, you should define a default currency:
Creating or Updating Currencies
The save() method handles both creation and updates based on currency code:
Retrieving Currencies
Or, available DI way
Manual Rate Management
If you're not using an automatic rate provider, you can manually manage rates:
Or more custom way:
Deleting the currencies
Currency Administration Tips
Initial Setup
- Always set up a default currency first
- Use standardized 3-letter ISO currency codes
- Consider implementing a seeder for basic currencies
Rate Management
- Update rates regularly if managing manually
- Consider implementing a schedule for rate updates
- Keep historical rates for reporting
Best Practices
- Validate currency codes before saving
- Handle rate update failures gracefully
- Consider implementing rate validity periods
- Add logging for important currency operations
Basic Usage
of if you prefer Di, you can inject it and use:
Advanced Usage
Working with Exchange Rate History
Custom Rate Providers
You can create your own rate providers by implementing CurrencyRateProviderInterface:
Then register it in your configuration:
Exception Handling
The service throws the following exceptions:
- CurrencyNotFoundException - When a requested currency doesn't exist
- CurrencyRateNotFoundException - When an exchange rate is not available
- CurrencyProviderException - When there's an error fetching rates
- NoCurrencyException - When no default currency is set
Testing
License
MIT License. See the LICENSE file for details.
All versions of currency-service with dependencies
laravel/framework Version ^10.0
guzzlehttp/guzzle Version ^7.0
ext-json Version *