redcode/currency-rate
A Laravel package for fetching and managing currency exchange rates. Retrieve rates from configurable providers, cache results, and convert amounts between currencies through a simple, expressive API—useful for pricing, invoices, and multi-currency applications.
Install the library with Composer and verify it actually resolves against your PHP version before writing any code:
composer require redcode/currency-rate
Be aware up front that the last tagged release is from September 2015 and the package has essentially no downstream usage. The first thing to do is open vendor/redcode/currency-rate/src and read the source directly — the public footprint is small, and there is no meaningful documentation beyond the README. You are looking for the loader/parser classes and the provider classes that fetch rates from external services.
Your first use case will almost always be the same: convert a stored amount from one currency to another using today's rate. A minimal flow looks like:
$loader = new \RedCode\CurrencyRate\Loader\...; // whichever loader the package ships
$rates = $loader->load(); // returns a collection of rates
$rate = $rates->getRate('EUR', 'USD');
$converted = $amount * $rate;
Because the library is a plain PHP package (not a Laravel package), there is no service provider, no facade, and no config file. You wire it in yourself. Treat it as a low-level building block, not framework glue.
Wrap it, don't sprinkle it. The library has no Laravel integration, so create a single application service that owns it:
class ExchangeRateService
{
public function __construct(private RateRepository $repo) {}
public function rate(string $from, string $to): float
{
// read from your DB cache first, fall back to the package
}
}
Bind this in a service provider and inject it where needed. This isolates you from the package's API and makes it trivial to swap it out later (which you probably will).
Cache aggressively in your own storage. The package does not give you Laravel caching, DB persistence, or a scheduler. Exchange rates change at most a few times per day, and provider endpoints are rate-limited. The standard pattern:
php artisan rates:refresh) runs on a cron / schedule().currency_rates table (base, quote, rate, fetched_at).Store a base currency and derive pairs when you need cross-rates (USD→PLN via EUR), because most free feeds are anchored to a single base (commonly EUR or USD). Doing the triangulation yourself avoids depending on which pairs the provider happens to publish.
Use it in a fallback chain across providers. The package's value is that it exposes a common shape over multiple feeds. Register one primary provider and one backup, and call them in order in your refresh command. This is the one genuine benefit the library offers — you get a uniform loader interface for feeds you would otherwise parse by hand.
Guard conversions at the boundary. Any place you display money, resolve the rate once per request (or read it from a cached array), and convert at the edge. Do not convert back and forth — rounding will drift.
composer audit and expect it to be flagged eventually. Plan an exit.composer require --ignore-platform-reqs (risky) or fork it. Check for mcrypt, old curl usage, or each()-style calls that were removed from modern PHP.LoaderInterface) pointing at a maintained source like the ECB XML feed or exchangerate.host. That preserves the abstraction while removing the dead provider code.moneyphp/money for the math side) gives you the same result with maintained code, tests, and modern PHP support. Use redcode/currency-rate only if you are inheriting it and need a stopgap — and isolate it behind your own service so removing it is a one-file change.How can I help you explore Laravel packages today?