moneyphp/iso-currencies
Up-to-date ISO 4217 currency list for MoneyPHP, sourced from the official ISO 4217 Maintenance Agency (currency-iso.org). Includes tooling to fetch and update the currency dataset via Composer for use with moneyphp/money.
Laravel/PHP Stack Alignment: The package is architecturally lightweight and complements Laravel’s dependency injection (DI) and service container natively. Its static, immutable currency dataset (ISO 4217) ensures zero runtime overhead, making it ideal for performance-sensitive applications like payment gateways, financial APIs, or multi-currency e-commerce platforms. The historical currency flagging (e.g., BGN post-2026) aligns with Laravel’s need for data consistency and regulatory compliance in distributed systems. The package’s MIT license and Composer-driven updates further reduce integration complexity.
Key Fit Areas:
moneyphp/money (e.g., invoicing, subscriptions, or financial reporting).Integration Feasibility:
moneyphp/money, enabling plug-and-play integration with Laravel. Example use cases:
CurrencyRepository::getAll() for ISO-compliant currency metadata.CurrencyRepository::getCurrency('EUR') to fetch symbols, decimal precision, or historical status dynamically.Money objects).Technical Risk:
moneyphp/money, which may limit flexibility if using alternative libraries (e.g., league/money). Mitigation:
CurrencyService interface).composer fetch-update (e.g., via CI/CD or cron) to sync with ISO changes.2.0.0) introduced breaking changes (e.g., removed current.json). Mitigation:
platform-check to avoid unintended version conflicts.CurrencyRepository decorator) for non-ISO needs.Key Questions:
moneyphp/money?
Money object integration) is a blocker.composer fetch-update (e.g., weekly CI/CD runs) to avoid stale data.CurrencyRepository or use a decorator pattern).Laravel Compatibility: The package integrates natively with Laravel’s service container and dependency injection. Key integration points:
CurrencyRepository as a singleton in AppServiceProvider:
$this->app->singleton(CurrencyRepository::class, function ($app) {
return new CurrencyRepository();
});
Currency facade for cleaner syntax (e.g., Currency::getAll()).MoneyPHP Alignment:
moneyphp/money + iso-currencies:
use Money\Currency\Currency;
use Money\Currency\CurrencyRepository;
$eur = $currencyRepository->getCurrency('EUR');
$amount = new Money(1000, $eur);
if (!$currencyRepository->getCurrency('XXX')) {
throw new InvalidArgumentException('Invalid currency code.');
}
Historical Currency Handling:
isHistorical() method to filter deprecated currencies (e.g., BGN post-2026):
$historicalCurrencies = array_filter(
$currencyRepository->getAll(),
fn(Currency $c) => $c->isHistorical()
);
currency_code column with check constraints referencing the ISO list.Assessment Phase:
Pilot Integration:
composer require moneyphp/iso-currencies
Full Migration:
CurrencyRepository in core services (e.g., PaymentService, InvoiceGenerator).currency_code foreign keys).composer fetch-update weekly).Validation Layer:
use Money\Currency\CurrencyRepository;
public function rules()
{
return [
'currency' => ['required', function ($attribute, $value, $fail) {
$repo = app(CurrencyRepository::class);
if (!$repo->getCurrency($value)) {
$fail('The ' . $attribute . ' must be a valid ISO currency code.');
}
}],
];
}
platform constraints to pin a compatible version.moneyphp/money v3.0+. Mitigation for older versions:
moneyphp/money or abstract the repository to work with older APIs.composer require moneyphp/iso-currencies moneyphp/m
How can I help you explore Laravel packages today?