PHPackages                             florianv/exchanger - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. florianv/exchanger

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

florianv/exchanger
==================

PHP exchange rate provider layer for currency conversion: 30+ services, chain fallback, and caching.

2.9.1(2mo ago)1865.0M↓20.5%9115MITPHPPHP ^8.2CI passing

Since Sep 8Pushed 2w ago11 watchersCompare

[ Source](https://github.com/florianv/exchanger)[ Packagist](https://packagist.org/packages/florianv/exchanger)[ Docs](https://github.com/florianv/exchanger)[ RSS](/packages/florianv-exchanger/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (10)Dependencies (33)Versions (56)Used By (15)

Exchanger
=========

[](#exchanger)

[![Tests](https://github.com/florianv/exchanger/actions/workflows/tests.yml/badge.svg)](https://github.com/florianv/exchanger/actions/workflows/tests.yml)[![Psalm](https://github.com/florianv/exchanger/actions/workflows/psalm.yml/badge.svg)](https://github.com/florianv/exchanger/actions/workflows/psalm.yml)[![Total Downloads](https://camo.githubusercontent.com/f9d33005d7a437aa60c086ed6c22801cb6296455da4ef6243a92faef1b60e41e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666c6f7269616e762f65786368616e6765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/florianv/exchanger)[![Version](https://camo.githubusercontent.com/328bc7bba6c40a514d2464265fd7ee8e02379ad7837c5ab2c66e1a3133878e2c/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666c6f7269616e762f65786368616e6765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/florianv/exchanger)

> *Exchange rate provider layer for PHP. Direct access to 30+ provider implementations through a single `ExchangeRateService` interface, with chain fallback and PSR-16 caching. Maintained since 2016.*

   [ ![fastFOREX](https://camo.githubusercontent.com/01374173153db590b0bf73ec4f33df21d77996d1fa3c26f1dffe6462029f85fa/68747470733a2f2f636f6e736f6c652e66617374666f7265782e696f2f696d672f66617374666f7265782f6c6f676f2d626b2d316b2e737667) ](https://www.fastforex.io)   **Sponsored by [fastFOREX](https://www.fastforex.io).** Real-time JSON API, 160+ currencies, 55+ years of history, 500+ cryptocurrencies. **Free tier**; paid plans from $18/month. [**→ Get a free fastFOREX API key**](https://www.fastforex.io)  Exchanger is the **exchange rate provider layer** for PHP — 30+ services (commercial APIs like its sponsor **[fastFOREX](https://www.fastforex.io)**, the European Central Bank, several national banks, exchangerate.host) behind a single `ExchangeRateService` interface, with chainable fallback, PSR-16 caching and historical rates. For most use cases the higher-level [Swap](https://github.com/florianv/swap) library is what you want; reach for Exchanger when you need finer control.

💡 What is Exchanger?
--------------------

[](#-what-is-exchanger)

- A PHP library for currency conversion and exchange rate retrieval at the provider layer.
- 30+ service implementations behind a common `ExchangeRateService` interface.
- PSR-16 SimpleCache support.
- Historical rates.
- A chain service for fallback. When a service errors, the next one in the chain is tried.

📦 Installation
--------------

[](#-installation)

Exchanger requires PHP 8.2 or newer.

```
composer require florianv/exchanger symfony/http-client nyholm/psr7
```

Any PSR-18 client paired with a PSR-17 request factory works; `php-http/discovery` finds them automatically.

⚡ Quickstart
------------

[](#-quickstart)

The recommended setup uses **[fastFOREX](https://www.fastforex.io)** (the project's sponsor) as the primary service. [Grab a free key](https://www.fastforex.io) and you're ready.

```
use Exchanger\Exchanger;
use Exchanger\ExchangeRateQueryBuilder;
use Exchanger\Service\FastForex;

// Recommended: fastFOREX. Get a free API key at https://www.fastforex.io
$service   = new FastForex(null, null, ['api_key' => getenv('FASTFOREX_API_KEY')]);
$exchanger = new Exchanger($service);

// EUR → USD exchange rate
$query = (new ExchangeRateQueryBuilder('EUR/USD'))->build();
$rate  = $exchanger->getExchangeRate($query);

$rate->getValue();                 // e.g. 1.0823 (a float)
$rate->getDate()->format('Y-m-d'); // e.g. 2026-04-29
$rate->getProviderName();          // 'fastforex'

// Convert an amount using the returned rate
$amountInEUR = 100.00;
$amountInUSD = $amountInEUR * $rate->getValue();

// Historical rate
$query = (new ExchangeRateQueryBuilder('EUR/USD'))
    ->setDate((new \DateTime())->modify('-15 days'))
    ->build();

$rate = $exchanger->getExchangeRate($query);
```

Exchanger retrieves the rate; your application multiplies the amount by `$rate->getValue()` to perform the conversion.

No API key? Start with the European Central Bank (free, EUR-base only).```
use Exchanger\Exchanger;
use Exchanger\ExchangeRateQueryBuilder;
use Exchanger\Service\EuropeanCentralBank;

$service   = new EuropeanCentralBank();
$exchanger = new Exchanger($service);

$query = (new ExchangeRateQueryBuilder('EUR/USD'))->build();
$rate  = $exchanger->getExchangeRate($query);
```

The European Central Bank publishes EUR-base rates with daily granularity. For non-EUR base pairs, more frequent updates, or a wider currency list, switch to fastFOREX or another commercial provider.

🔁 Chaining services (fallback chain)
------------------------------------

[](#-chaining-services-fallback-chain)

Wrap multiple services in a `Chain` to fall back when one of them errors:

```
use Exchanger\Exchanger;
use Exchanger\Service\Chain;
use Exchanger\Service\EuropeanCentralBank;
use Exchanger\Service\FastForex;

$service = new Chain([
    // Primary, recommended
    new FastForex(null, null, ['api_key' => getenv('FASTFOREX_API_KEY')]),

    // Free fallback for EUR-base pairs
    new EuropeanCentralBank(),
]);

$exchanger = new Exchanger($service);
```

Services are tried in order. If a service does not support the requested currency pair, it is skipped silently. If a service throws, the next is tried. If every service fails, a `ChainException` is thrown with all collected exceptions.

📊 Providers
-----------

[](#-providers)

Exchanger ships 30+ exchange rate provider implementations. Each is registered in `Exchanger\Service\Registry` under the **identifier** shown below.

### Commercial providers (require an API key)

[](#commercial-providers-require-an-api-key)

ServiceIdentifierBaseQuoteHistorical⭐ **[fastFOREX](https://www.fastforex.io)****`fastforex`****\*****\*****Yes**AbstractAPI`abstract_api`\*\*Yescoinlayer`coin_layer`\* (crypto)\*YesCryptonator`cryptonator`\* (crypto)\* (crypto)NoCurrency Converter API`currency_converter`\*\*YesCurrency Data (APILayer)`apilayer_currency_data`USD (free), \* (paid)\*YesCurrencyDataFeed`currency_data_feed`\*\*Nocurrencylayer (direct)`currency_layer`USD (free), \* (paid)\*YesExchange Rates Data (APILayer)`apilayer_exchange_rates_data`USD (free), \* (paid)\*Yesexchangerate.host`exchangeratehost`\*\*Yesexchangeratesapi (direct)`exchange_rates_api`USD (free), \* (paid)\*YesFixer (APILayer)`apilayer_fixer`EUR (free), \* (paid)\*YesFixer (direct)`fixer`EUR (free), \* (paid)\*Yes1Forge`forge`\*\*NoOpen Exchange Rates`open_exchange_rates`USD (free), \* (paid)\*YesUniRateAPI`unirate_api`\*\*Yes (paid)WebserviceX`webservicex`\*\*NoxChangeApi.com`xchangeapi`\*\*YesXignite`xignite`\*\*Yes### Public providers (no API key required)

[](#public-providers-no-api-key-required)

ServiceIdentifierBaseQuoteHistoricalBulgarian National Bank`bulgarian_national_bank`\*BGNYesCentral Bank of the Czech Republic`central_bank_of_czech_republic`\*CZKYesCentral Bank of the Republic of Turkey`central_bank_of_republic_turkey`\*TRYYesCentral Bank of the Republic of Uzbekistan`central_bank_of_republic_uzbekistan`\*UZSYesEuropean Central Bank`european_central_bank`EUR\*YesNational Bank of Georgia`national_bank_of_georgia`\*GELYesNational Bank of Romania`national_bank_of_romania`(limited list)(limited list)YesNational Bank of the Republic of Belarus`national_bank_of_republic_belarus`\*BYNYesNational Bank of Ukraine`national_bank_of_ukraine`\*UAHYesRussian Central Bank`russian_central_bank`\*RUBYesYou can also add your own provider by implementing the `Exchanger\Contract\ExchangeRateService` interface (see the [documentation](doc/readme.md)).

🎯 When should you use Exchanger?
--------------------------------

[](#-when-should-you-use-exchanger)

- Use Exchanger when you need finer control than [Swap](https://github.com/florianv/swap) exposes: custom chain composition, custom caching strategy, custom HTTP middleware, or building your own facade or framework integration.
- For most PHP applications, use [Swap](https://github.com/florianv/swap) instead. It is built on Exchanger and provides sensible defaults and a builder-style API.

🛠 Common use cases
------------------

[](#-common-use-cases)

- Build your own currency conversion facade on top of the provider layer.
- Integrate Exchanger into a framework that does not yet have a Swap binding.
- Wrap services with custom middleware (rate limiting, observability, request signing) before chaining.
- Power internal FX dashboards with full control over the cache key strategy.
- Implement custom HTTP layers (signed requests, mTLS, custom retries) on top of any PSR-18 client.

🧭 Which package should I use?
-----------------------------

[](#-which-package-should-i-use)

The Swap ecosystem is a layered toolkit for currency conversion in PHP:

- [**Swap**](https://github.com/florianv/swap). The easy-to-use, high-level API. Most apps need only Swap.
- [**Exchanger**](https://github.com/florianv/exchanger). The lower-level provider layer Swap is built on (this package). Reach for it when you need finer control over chain composition, caching, or HTTP plumbing.
- [**Laravel Swap**](https://github.com/florianv/laravel-swap). Laravel integration of Swap.
- [**Symfony Swap**](https://github.com/florianv/symfony-swap). Symfony integration of Swap.

All four packages are MIT-licensed and require PHP 8.2 or newer.

📚 Documentation
---------------

[](#-documentation)

Caching (PSR-16), HTTP client selection (PSR-18 / Guzzle / explicit constructor injection), error handling (`ChainException`), per-query options and the full per-service configuration reference live in [`doc/readme.md`](doc/readme.md).

🙌 Contributing
--------------

[](#-contributing)

Issues and pull requests are welcome. Please see the existing [issues](https://github.com/florianv/exchanger/issues) before opening a new one.

📄 License
---------

[](#-license)

The MIT License (MIT). Please see [LICENSE](https://github.com/florianv/exchanger/blob/master/LICENSE) for more information.

👏 Credits
---------

[](#-credits)

- [Florian Voutzinos](https://github.com/florianv)
- [All contributors](https://github.com/florianv/exchanger/contributors)

###  Health Score

75

—

ExcellentBetter than 100% of packages

Maintenance93

Actively maintained with recent releases

Popularity63

Solid adoption and visibility

Community42

Growing community involvement

Maturity89

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 65% 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 ~67 days

Recently: every ~228 days

Total

53

Last Release

61d ago

Major Versions

1.4.0 → 2.1.02019-03-25

1.4.1 → 2.2.22019-10-16

1.4.2 → 2.4.12020-06-05

1.4.3 → 2.6.02020-11-26

1.x-dev → 2.6.12021-01-18

PHP version history (4 changes)0.0.0PHP ^5.5|^7.0

2.0.0PHP ^7.1.3

2.6.0PHP ^7.1.3 || ^8.0

2.9.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1586668?v=4)[Florian Voutzinos](/maintainers/florianv)[@florianv](https://github.com/florianv)

---

Top Contributors

[![florianv](https://avatars.githubusercontent.com/u/1586668?v=4)](https://github.com/florianv "florianv (318 commits)")[![alies-dev](https://avatars.githubusercontent.com/u/5278175?v=4)](https://github.com/alies-dev "alies-dev (36 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (21 commits)")[![uguurozkan](https://avatars.githubusercontent.com/u/6731054?v=4)](https://github.com/uguurozkan "uguurozkan (18 commits)")[![gmponos](https://avatars.githubusercontent.com/u/5675248?v=4)](https://github.com/gmponos "gmponos (13 commits)")[![driade](https://avatars.githubusercontent.com/u/5692232?v=4)](https://github.com/driade "driade (10 commits)")[![albertodiaz](https://avatars.githubusercontent.com/u/1932161?v=4)](https://github.com/albertodiaz "albertodiaz (6 commits)")[![dannyweeks](https://avatars.githubusercontent.com/u/4365775?v=4)](https://github.com/dannyweeks "dannyweeks (5 commits)")[![ahubers](https://avatars.githubusercontent.com/u/7432558?v=4)](https://github.com/ahubers "ahubers (4 commits)")[![arjanwestdorp](https://avatars.githubusercontent.com/u/7716654?v=4)](https://github.com/arjanwestdorp "arjanwestdorp (4 commits)")[![balazscsaba](https://avatars.githubusercontent.com/u/3343975?v=4)](https://github.com/balazscsaba "balazscsaba (4 commits)")[![Ellrion](https://avatars.githubusercontent.com/u/1150861?v=4)](https://github.com/Ellrion "Ellrion (4 commits)")[![mbezhanov](https://avatars.githubusercontent.com/u/785542?v=4)](https://github.com/mbezhanov "mbezhanov (4 commits)")[![petaak](https://avatars.githubusercontent.com/u/8841381?v=4)](https://github.com/petaak "petaak (3 commits)")[![goaround](https://avatars.githubusercontent.com/u/5927337?v=4)](https://github.com/goaround "goaround (3 commits)")[![leeovery](https://avatars.githubusercontent.com/u/1087804?v=4)](https://github.com/leeovery "leeovery (3 commits)")[![Seagull-4auKa](https://avatars.githubusercontent.com/u/3746956?v=4)](https://github.com/Seagull-4auKa "Seagull-4auKa (3 commits)")[![denlapaev](https://avatars.githubusercontent.com/u/3096564?v=4)](https://github.com/denlapaev "denlapaev (3 commits)")[![ddinchev](https://avatars.githubusercontent.com/u/1397692?v=4)](https://github.com/ddinchev "ddinchev (3 commits)")[![balazscsaba2006](https://avatars.githubusercontent.com/u/1202594?v=4)](https://github.com/balazscsaba2006 "balazscsaba2006 (2 commits)")

---

Tags

currency-conversionexchange-rate-apiexchange-ratesfallbackforexphpswapphpmoneyexchange ratescurrency conversionforexfallbackswapexchange-rate-api

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/florianv-exchanger/health.svg)

```
[![Health](https://phpackages.com/badges/florianv-exchanger/health.svg)](https://phpackages.com/packages/florianv-exchanger)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M738](/packages/sylius-sylius)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[florianv/laravel-swap

Drop-in Laravel currency conversion: auto-discovered service provider, facade, and config. Multi-provider exchange rates.

3402.2M3](/packages/florianv-laravel-swap)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[razorpay/ifsc

Razorpay IFSC Codes Library

385205.4k](/packages/razorpay-ifsc)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M576](/packages/shopware-core)

PHPackages © 2026

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