PHPackages                             florianv/swap-bundle - 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. florianv/swap-bundle

ActiveSymfony-bundle[API Development](/categories/api)

florianv/swap-bundle
====================

Drop-in Symfony bundle for currency conversion: configurable services, multi-provider exchange rates with fallback and caching.

6.0.0(3mo ago)64431.5k↓44.6%331MITPHPPHP ^8.2CI failing

Since May 31Pushed 2w ago5 watchersCompare

[ Source](https://github.com/florianv/symfony-swap)[ Packagist](https://packagist.org/packages/florianv/swap-bundle)[ Docs](https://github.com/florianv/FlorianvSwapBundle)[ RSS](/packages/florianv-swap-bundle/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (16)Versions (26)Used By (1)

Symfony Swap
============

[](#symfony-swap)

[![Tests](https://github.com/florianv/symfony-swap/actions/workflows/tests.yml/badge.svg)](https://github.com/florianv/symfony-swap/actions/workflows/tests.yml)[![Psalm](https://github.com/florianv/symfony-swap/actions/workflows/psalm.yml/badge.svg)](https://github.com/florianv/symfony-swap/actions/workflows/psalm.yml)[![Total Downloads](https://camo.githubusercontent.com/584b5098b735eee7f156dcab0c23493404f6e8d5ed74942ace6d24fe2d33dd20/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666c6f7269616e762f737761702d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/florianv/swap-bundle)[![Version](https://camo.githubusercontent.com/ab4a09346cfc175f5c29615c21f2fb0c15293fd95c466c223c6afd5b523a1c75/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666c6f7269616e762f737761702d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/florianv/swap-bundle)

> *Drop-in Symfony bundle for currency conversion. Multi-provider exchange rates with fallback, caching, and Symfony Cache integration. Maintained since 2014.*

   [ ![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)  **Install the bundle, drop a `florianv_swap.yaml` in `config/packages/`, and the `florianv_swap.swap` service is ready to inject. No service container plumbing, no boilerplate.**

Symfony Swap is a drop-in package for **Symfony currency conversion**. Install it, configure providers in `config/packages/florianv_swap.yaml`, and pull exchange rates from multiple providers in one call. The bundle integrates with Symfony Cache out of the box and supports Symfony 6.4 / 7 / 8.

💡 What is Symfony Swap?
-----------------------

[](#-what-is-symfony-swap)

- The Symfony integration of [Swap](https://github.com/florianv/swap), the PHP currency conversion library.
- Registers a `florianv_swap.swap` service in the container (`Swap\Swap` class).
- Configuration lives in `config/packages/florianv_swap.yaml`.
- Caching uses Symfony Cache (`array`, `apcu`, `filesystem`, or any PSR-16 service ID).
- Providers are tried in priority order (higher priority first).

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

[](#-installation)

Symfony Swap requires PHP 8.2 or newer and Symfony 6.4, 7, or 8.

```
composer require florianv/swap-bundle symfony/http-client nyholm/psr7
```

Register the bundle in `config/bundles.php` (Symfony Flex skips this step if a recipe applies):

```
// config/bundles.php
return [
    // ...
    Florianv\SwapBundle\FlorianvSwapBundle::class => ['all' => true],
];
```

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

[](#-quickstart)

Configure providers in `config/packages/florianv_swap.yaml`. The recommended primary provider is **[fastFOREX](https://www.fastforex.io)** (the project's sponsor): a real-time JSON API behind a single `api_key`, [free tier available](https://www.fastforex.io).

```
# config/packages/florianv_swap.yaml
florianv_swap:
    cache:
        ttl: 3600
        type: filesystem
    providers:
        fastforex:
            api_key: '%env(SWAP_FASTFOREX_KEY)%'
            priority: 10              # tried first
        european_central_bank:
            priority: 0               # free fallback for EUR-base pairs
```

Inject the service:

```
use Swap\Swap;
use Symfony\Component\DependencyInjection\Attribute\Autowire;

final class CurrencyController
{
    public function __construct(
        #[Autowire(service: 'florianv_swap.swap')]
        private readonly Swap $swap,
    ) {}

    public function rate(): array
    {
        // EUR → USD exchange rate
        $rate = $this->swap->latest('EUR/USD');

        return [
            'value'    => $rate->getValue(),                 // e.g. 1.0823
            'date'     => $rate->getDate()->format('Y-m-d'), // e.g. 2026-04-29
            'provider' => $rate->getProviderName(),          // 'fastforex'
        ];
    }
}
```

Or fetch directly from the container:

```
$swap = $container->get('florianv_swap.swap');
$rate = $swap->latest('EUR/USD');
```

Providers are tried in priority order (higher first). If a provider does not support the requested currency pair, it is skipped silently. If a provider throws an error, the next provider is tried. If every provider fails, a `ChainException` is thrown with all collected errors.

No API key? Start with the European Central Bank (free, EUR-base only).```
# config/packages/florianv_swap.yaml
florianv_swap:
    providers:
        european_central_bank:
            priority: 0
```

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.

💾 Caching
---------

[](#-caching)

Set `cache` in `config/packages/florianv_swap.yaml`:

```
# config/packages/florianv_swap.yaml
florianv_swap:
    cache:
        ttl: 3600
        type: filesystem   # array, apcu, filesystem, or a PSR-16 service ID
```

For a custom cache, point `type` at any service implementing `Psr\SimpleCache\CacheInterface`:

```
florianv_swap:
    cache:
        ttl: 3600
        type: my_psr16_cache_service
```

Per-query overrides are documented in the [full documentation](Resources/doc/index.md#-per-query-options).

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

[](#-providers)

Symfony Swap supports the 30+ exchange rate providers from the underlying [Swap](https://github.com/florianv/swap) library. Pass the **identifier** as the key under `providers` in `config/packages/florianv_swap.yaml`.

### 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)\*YesWebserviceX`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`\*RUBYesThe per-provider option names (`api_key` vs `access_key` vs `app_id`, optional flags) are documented in [Provider configuration](Resources/doc/index.md#provider-configuration).

🎯 When should you use Symfony Swap?
-----------------------------------

[](#-when-should-you-use-symfony-swap)

- Use Symfony Swap when you need exchange rates inside a Symfony application: localized prices, invoice totals, multi-currency reporting, historical FX data.
- You do not need to install [Swap](https://github.com/florianv/swap) separately. It is pulled in as a dependency, and Symfony Swap exposes it through Symfony's container and cache.

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

[](#-common-use-cases)

- Display localized prices in multi-currency Symfony storefronts.
- Compute invoice totals across currencies in a Symfony API.
- Reconcile multi-currency ledgers using historical rates.
- Power internal FX dashboards with rate history.
- Build currency conversion infrastructure for Symfony-based fintech and ERP applications.

🧭 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 for plain PHP.
- [**Exchanger**](https://github.com/florianv/exchanger). Lower-level, more granular alternative; direct access to provider implementations.
- [**Laravel Swap**](https://github.com/florianv/laravel-swap). Laravel application of Swap.
- [**Symfony Swap**](https://github.com/florianv/symfony-swap). Symfony integration of Swap (this package).

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

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

[](#-documentation)

The full documentation, with the per-provider configuration reference, custom service registration, cache types, and FAQ, is in [Resources/doc/index.md](Resources/doc/index.md).

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

[](#-contributing)

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

📄 License
---------

[](#-license)

The MIT License (MIT). Please see [LICENSE](LICENSE) for more information.

👏 Credits
---------

[](#-credits)

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

###  Health Score

68

—

FairBetter than 99% of packages

Maintenance89

Actively maintained with recent releases

Popularity51

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 66.7% 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 ~195 days

Recently: every ~424 days

Total

23

Last Release

117d ago

Major Versions

1.x-dev → v2.0.02015-05-28

v2.3.0 → v3.0.02018-03-24

3.x-dev → 4.0.02019-07-29

4.1.0 → 5.0.02020-03-04

v5.5.0 → 6.0.02026-03-09

PHP version history (3 changes)v3.0.0PHP ^5.6|^7.0

5.2PHP ^7.1.3|^8.0

6.0.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 (76 commits)")[![alies-dev](https://avatars.githubusercontent.com/u/5278175?v=4)](https://github.com/alies-dev "alies-dev (14 commits)")[![xterr](https://avatars.githubusercontent.com/u/619509?v=4)](https://github.com/xterr "xterr (3 commits)")[![marcortola](https://avatars.githubusercontent.com/u/15958009?v=4)](https://github.com/marcortola "marcortola (3 commits)")[![Chris8934](https://avatars.githubusercontent.com/u/44963939?v=4)](https://github.com/Chris8934 "Chris8934 (2 commits)")[![anorgan](https://avatars.githubusercontent.com/u/1270389?v=4)](https://github.com/anorgan "anorgan (2 commits)")[![ping-localhost](https://avatars.githubusercontent.com/u/37925797?v=4)](https://github.com/ping-localhost "ping-localhost (2 commits)")[![hdimo](https://avatars.githubusercontent.com/u/2865108?v=4)](https://github.com/hdimo "hdimo (1 commits)")[![lalex](https://avatars.githubusercontent.com/u/869741?v=4)](https://github.com/lalex "lalex (1 commits)")[![luxifer](https://avatars.githubusercontent.com/u/419078?v=4)](https://github.com/luxifer "luxifer (1 commits)")[![ugurerkan](https://avatars.githubusercontent.com/u/473959?v=4)](https://github.com/ugurerkan "ugurerkan (1 commits)")[![dragosprotung](https://avatars.githubusercontent.com/u/1081073?v=4)](https://github.com/dragosprotung "dragosprotung (1 commits)")[![remmel](https://avatars.githubusercontent.com/u/937836?v=4)](https://github.com/remmel "remmel (1 commits)")[![ruudk](https://avatars.githubusercontent.com/u/104180?v=4)](https://github.com/ruudk "ruudk (1 commits)")[![sfblaauw](https://avatars.githubusercontent.com/u/2537172?v=4)](https://github.com/sfblaauw "sfblaauw (1 commits)")[![stephpy](https://avatars.githubusercontent.com/u/232744?v=4)](https://github.com/stephpy "stephpy (1 commits)")[![stevenbrookes](https://avatars.githubusercontent.com/u/43211757?v=4)](https://github.com/stevenbrookes "stevenbrookes (1 commits)")[![ekyna](https://avatars.githubusercontent.com/u/3483641?v=4)](https://github.com/ekyna "ekyna (1 commits)")[![chekalsky](https://avatars.githubusercontent.com/u/241584?v=4)](https://github.com/chekalsky "chekalsky (1 commits)")

---

Tags

currency-conversionexchange-rate-apiexchange-ratesphpswapsymfonysymfony-bundlesymfonybundlemoneycurrencyconversionRateexchange

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[web-auth/webauthn-symfony-bundle

FIDO2/Webauthn Security Bundle For Symfony

66529.9k11](/packages/web-auth-webauthn-symfony-bundle)[maciej-sz/nbp-php

API for accessing Polish National Bank (NBP - Narodowy Bank Polski) currency and commodities exchange rates

1447.4k1](/packages/maciej-sz-nbp-php)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k13](/packages/2lenet-crudit-bundle)[stfalcon-studio/api-bundle

Base classes and helper services to build API application via Symfony.

1035.6k](/packages/stfalcon-studio-api-bundle)

PHPackages © 2026

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