Laravel Currency
Currency conversion, exchange rates and money formatting for Laravel. Rates come from pluggable providers — Ukrainian banks (Monobank, PrivatBank, NBU) and international APIs (jsDelivr currency-api, ExchangeRatesAPI / frankfurter, CurrencyAPI, Fixer) — and are cached with a fallback for when the API is down.
- Conversion with buy / sell / average rates
- Seven built-in providers, switchable at runtime, plus your own via a small contract
- Historical rates — convert at the rate of a past date
- Base currency override — rates recalculated relative to any currency the provider knows
- Caching with a long-term fallback cache and a
CurrencyRateFetchFailedevent for alerting - Formatting — symbol, precision, separators per currency
- Global helpers, Blade directives and two Artisan commands
Quick example
Section titled “Quick example”use Fomvasss\Currency\Facades\Currency;
Currency::convert(100, 'USD', 'UAH'); // 100 USD in UAH at the average rateCurrency::convert(100, 'USD', 'UAH', 'sell'); // at the bank's selling rateCurrency::getRate('EUR'); // UAH per 1 EURCurrency::format(1234.5, 'USD'); // "$ 1,234.50"
Currency::useProvider('nbu') ->convertAt(100, 'USD', 'UAH', now()->subYear()); // rate as of a year agophp artisan currency:rates --provider=nbuphp artisan currency:convert 100 usd eur --formatContents
Section titled “Contents”Getting started
Usage
- Converting & rates
- Rate providers
- Base currency
- Historical rates
- Formatting & currencies
- Helpers & Blade
- Caching & failures
- Custom providers
Reference