PHPackages                             rapidwebltd/simple-currency-rates - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. rapidwebltd/simple-currency-rates

ActiveLibrary[API Development](/categories/api)

rapidwebltd/simple-currency-rates
=================================

This package provides simple access to current currency exchange rates.

v1.1.2(8y ago)130LGPL-3.0-onlyPHPCI passing

Since Jan 5Pushed 3w ago2 watchersCompare

[ Source](https://github.com/rapidwebltd/simple-currency-rates)[ Packagist](https://packagist.org/packages/rapidwebltd/simple-currency-rates)[ RSS](/packages/rapidwebltd-simple-currency-rates/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (5)Dependencies (2)Versions (5)Used By (0)

Simple Currency Rates
=====================

[](#simple-currency-rates)

Simple Currency Rates provides current fiat and Bitcoin exchange rates through a small, framework-independent PHP API. It supports PHP 5.6 through current PHP releases.

By default, fiat rates come from the keyless [Frankfurter API](https://frankfurter.dev/) and Bitcoin rates come from [Blockchain.com](https://www.blockchain.com/explorer/api/exchange_rates_api). Responses are cached on the local filesystem.

Installation
------------

[](#installation)

```
composer require rapidwebltd/simple-currency-rates
```

Usage
-----

[](#usage)

```
use RapidWeb\SimpleCurrencyRates\SimpleCurrencyRates;

$rates = (new SimpleCurrencyRates())->get('GBP');
```

The base currency is normalised to uppercase and always has a rate of `1.0`. Rates are returned as a currency-code-keyed array sorted alphabetically:

```
[
    'EUR' => 1.16,
    'GBP' => 1.0,
    'USD' => 1.35,
    'XBT' => 0.00001234,
]
```

The base must be a three-letter currency code. Network failures and invalid provider responses throw `RateSourceException` instead of returning incomplete data.

Using another cache
-------------------

[](#using-another-cache)

The constructor and `setCache()` accept PSR-16 caches, PSR-6 cache pools, and compatible objects exposing `get`, `set`, and optionally `has`. No PSR package is forced on applications that use the built-in cache.

```
$rates = new SimpleCurrencyRates($psr16Cache);

// Or replace it later.
$rates->setCache($psr6CachePool);
```

To change the built-in cache directory:

```
use RapidWeb\SimpleCurrencyRates\Cache\FilesystemCache;

$rates = new SimpleCurrencyRates(
    new FilesystemCache('/var/cache/my-application/currency-rates')
);
```

Using custom rate sources
-------------------------

[](#using-custom-rate-sources)

A source implements `RateSourceInterface` and returns positive rates keyed by three-letter currency code. `getCacheTtl()` returns its cache lifetime in seconds; return `0` to disable caching.

```
use RapidWeb\SimpleCurrencyRates\Contracts\RateSourceInterface;

class CompanyRateSource implements RateSourceInterface
{
    public function getRates($base)
    {
        return [
            'EUR' => 1.16,
            'USD' => 1.35,
        ];
    }

    public function getCacheTtl()
    {
        return 300;
    }
}
```

Pass sources as the second constructor argument, replace them with `setSources()`, or append one with `addSource()`:

```
$rates = new SimpleCurrencyRates($cache, [
    new CompanyRateSource(),
]);

$rates
    ->setSources([new CompanyRateSource()])
    ->addSource($anotherSource);
```

When multiple sources return the same currency, the later source wins. The requested base currency is always reset to `1.0`.

The bundled `FrankfurterRateSource` and `BlockchainBitcoinRateSource` accept an optional callable HTTP client, which is useful for application-specific transports and deterministic tests:

```
use RapidWeb\SimpleCurrencyRates\Sources\FrankfurterRateSource;

$source = new FrankfurterRateSource(function ($url) use ($httpClient) {
    return $httpClient->get($url)->getBody()->getContents();
});
```

Testing
-------

[](#testing)

```
composer install
vendor/bin/phpunit
```

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance62

Regular maintenance activity

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Total

4

Last Release

3124d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c580cdf7c14898fff179cdfc1085892091d5d2f49d917873a12365af9ac77c93?d=identicon)[Jord-JD](/maintainers/Jord-JD)

---

Top Contributors

[![Jord-JD](https://avatars.githubusercontent.com/u/650645?v=4)](https://github.com/Jord-JD "Jord-JD (2 commits)")

---

Tags

currencycurrency-exchange-ratescurrency-rateslibraryphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rapidwebltd-simple-currency-rates/health.svg)

```
[![Health](https://phpackages.com/badges/rapidwebltd-simple-currency-rates/health.svg)](https://phpackages.com/packages/rapidwebltd-simple-currency-rates)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.5M7](/packages/exsyst-swagger)[lucasdotvin/laravel-soulbscription

A straightforward interface to handle subscriptions and features consumption.

709209.3k](/packages/lucasdotvin-laravel-soulbscription)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
