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

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

florianv/laravel-swap
=====================

Currency exchange rates library for Laravel and Lumen

2.4.0(2mo ago)3342.0M↑18.2%482MITPHPPHP ^8.2CI passing

Since Jun 10Pushed 2mo ago14 watchersCompare

[ Source](https://github.com/florianv/laravel-swap)[ Packagist](https://packagist.org/packages/florianv/laravel-swap)[ Docs](https://github.com/florianv/laravel-swap)[ RSS](/packages/florianv-laravel-swap/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (20)Used By (2)

[![](https://camo.githubusercontent.com/e9f2edc0c4c1fdecc071323f862b779f03a21b1b4d83746b97fbf4e01f607ac9/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f737761702e6173736574732f737761705f6c6f676f2e706e67)](https://camo.githubusercontent.com/e9f2edc0c4c1fdecc071323f862b779f03a21b1b4d83746b97fbf4e01f607ac9/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f737761702e6173736574732f737761705f6c6f676f2e706e67) Laravel Swap
======================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#-laravel-swap)

[![Tests](https://github.com/florianv/laravel-swap/actions/workflows/tests.yml/badge.svg)](https://github.com/florianv/laravel-swap/actions/workflows/tests.yml)[![Psalm](https://github.com/florianv/laravel-swap/actions/workflows/psalm.yml/badge.svg)](https://github.com/florianv/laravel-swap/actions/workflows/psalm.yml)[![Total Downloads](https://camo.githubusercontent.com/5b1edec1be0de53be65e1a93b3a34da132fd5be839d3ff0ea2a553bc3734d4fc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666c6f7269616e762f6c61726176656c2d737761702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/florianv/laravel-swap)[![Version](https://camo.githubusercontent.com/559537999e949ac5db42ad9bc20b98db735a41af9523078c7552f30fa6b73d75/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666c6f7269616e762f6c61726176656c2d737761702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/florianv/laravel-swap)

Swap allows you to retrieve currency exchange rates from various services such as **[Fixer](https://fixer.io/)**, **[Currency Data](https://currencylayer.com)**or **[Exchange Rates Data](https://exchangeratesapi.io)** and optionally cache the results.

Sponsors
--------

[](#sponsors)

  [![](https://camo.githubusercontent.com/0d10ffe181170f80111526baf4835225593324a3e10e8c3cf0f396549a9b6d9c/68747470733a2f2f6173736574732e6170696c617965722e636f6d2f617069732f66697865722e706e67)](https://camo.githubusercontent.com/0d10ffe181170f80111526baf4835225593324a3e10e8c3cf0f396549a9b6d9c/68747470733a2f2f6173736574732e6170696c617965722e636f6d2f617069732f66697865722e706e67) [Fixer](https://fixer.io/) is a simple and lightweight API for foreign exchange rates that supports up to 170 world currencies.   [![](https://camo.githubusercontent.com/7fcddd392c51aee3d78852b41590841f7186fab34870b5dc50f90989fd1a56b7/68747470733a2f2f6173736574732e6170696c617965722e636f6d2f617069732f63757272656e63795f646174612e706e67)](https://camo.githubusercontent.com/7fcddd392c51aee3d78852b41590841f7186fab34870b5dc50f90989fd1a56b7/68747470733a2f2f6173736574732e6170696c617965722e636f6d2f617069732f63757272656e63795f646174612e706e67) [Currency Data](https://currencylayer.com) provides reliable exchange rates and currency conversions for your business up to 168 world currencies.   [![](https://camo.githubusercontent.com/a1f40efebb340530a15ac4fb946a8657b802aece08961e29c8e3ca9cac2dba36/68747470733a2f2f6173736574732e6170696c617965722e636f6d2f617069732f65786368616e676572617465735f646174612e706e67)](https://camo.githubusercontent.com/a1f40efebb340530a15ac4fb946a8657b802aece08961e29c8e3ca9cac2dba36/68747470733a2f2f6173736574732e6170696c617965722e636f6d2f617069732f65786368616e676572617465735f646174612e706e67) [Exchange Rates Data](https://exchangeratesapi.io) provides reliable exchange rates and currency conversions for your business with over 15 data sources. QuickStart
----------

[](#quickstart)

### Installation

[](#installation)

```
$ composer require php-http/curl-client nyholm/psr7 php-http/message florianv/laravel-swap
```

### Laravel 5.7 or lesser

[](#laravel-57-or-lesser)

If you use cache, add also PSR-6 adapter and PSR-16 bridge cache dependencies :

```
$ composer require cache/illuminate-adapter cache/simple-cache-bridge
```

These dependencies are not required with Laravel 5.8 or greater which [implements PSR-16](https://github.com/laravel/framework/pull/27217).

### Laravel 5.5+

[](#laravel-55)

If you don't use auto-discovery, add the `ServiceProvider` to the providers array in `config/app.php`:

```
// /config/app.php
'providers' => [
    Swap\Laravel\SwapServiceProvider::class
],
```

If you want to use the facade to log messages, add this to your facades in app.php:

```
'aliases' => [
    'Swap' => Swap\Laravel\Facades\Swap::class
]

```

Copy the package config to your local config with the publish command:

```
$ php artisan vendor:publish --provider="Swap\Laravel\SwapServiceProvider"
```

### Lumen

[](#lumen)

Configure the Service Provider and alias:

```
// /boostrap/app.php

// Register the facade
$app->withFacades(true, [
    Swap\Laravel\Facades\Swap::class => 'Swap'
]);

// Load the configuration
$app->configure('swap');

// Register the service provider
$app->register(Swap\Laravel\SwapServiceProvider::class);
```

Copy the [configuration](config/swap.php) to `/config/swap.php` if you wish to override it.

Usage
-----

[](#usage)

```
// Get the latest EUR/USD rate
$rate = Swap::latest('EUR/USD');

// 1.129
$rate->getValue();

// 2016-08-26
$rate->getDate()->format('Y-m-d');

// Get the EUR/USD rate yesterday
$rate = Swap::historical('EUR/USD', Carbon\Carbon::yesterday());
```

Documentation
-------------

[](#documentation)

The complete documentation can be found [here](https://github.com/florianv/laravel-swap/blob/master/doc/readme.md).

Services
--------

[](#services)

Here is the list of the currently implemented services:

ServiceBase CurrencyQuote CurrencyHistorical[Fixer](https://fixer.io/)EUR (free, no SSL), \* (paid)\*Yes[Currency Data](https://currencylayer.com)USD (free), \* (paid)\*Yes[Exchange Rates Data](https://exchangeratesapi.io)USD (free), \* (paid)\*Yes[Abstract](https://www.abstractapi.com)\*\*Yes[coinlayer](https://coinlayer.com)\* Crypto (Limited standard currencies)\* Crypto (Limited standard currencies)Yes[Fixer](https://fixer.io)EUR (free, no SSL), \* (paid)\*Yes[currencylayer](https://currencylayer.com)USD (free), \* (paid)\*Yes[exchangeratesapi](https://exchangeratesapi.io)USD (free), \* (paid)\*Yes[European Central Bank](https://www.ecb.europa.eu/home/html/index.en.html)EUR\*Yes[National Bank of Georgia](https://nbg.gov.ge)\*GELYes[National Bank of the Republic of Belarus](https://www.nbrb.by)\*BYN (from 01-07-2016),
BYR (01-01-2000 - 30-06-2016),
BYB (25-05-1992 - 31-12-1999)Yes[National Bank of Romania](http://www.bnr.ro)RON, AED, AUD, BGN, BRL, CAD, CHF, CNY, CZK, DKK, EGP, EUR, GBP, HRK, HUF, INR, JPY, KRW, MDL, MXN, NOK, NZD, PLN, RSD, RUB, SEK, TRY, UAH, USD, XAU, XDR, ZARRON, AED, AUD, BGN, BRL, CAD, CHF, CNY, CZK, DKK, EGP, EUR, GBP, HRK, HUF, INR, JPY, KRW, MDL, MXN, NOK, NZD, PLN, RSD, RUB, SEK, TRY, UAH, USD, XAU, XDR, ZARYes[National Bank of Ukranie](https://bank.gov.ua)\*UAHYes[Central Bank of the Republic of Turkey](http://www.tcmb.gov.tr)\*TRYYes[Central Bank of the Republic of Uzbekistan](https://cbu.uz)\*UZSYes[Central Bank of the Czech Republic](https://www.cnb.cz)\*CZKYes[Central Bank of Russia](https://cbr.ru)\*RUBYes[Bulgarian National Bank](http://bnb.bg)\*BGNYes[WebserviceX](http://www.webservicex.net)\*\*No[1Forge](https://1forge.com)\* (free but limited or paid)\* (free but limited or paid)No[Cryptonator](https://www.cryptonator.com)\* Crypto (Limited standard currencies)\* Crypto (Limited standard currencies)No[CurrencyDataFeed](https://currencydatafeed.com)\* (free but limited or paid)\* (free but limited or paid)No[Open Exchange Rates](https://openexchangerates.org)USD (free), \* (paid)\*Yes[Xignite](https://www.xignite.com)\*\*Yes[Currency Converter API](https://www.currencyconverterapi.com)\*\*Yes (free but limited or paid)[xChangeApi.com](https://xchangeapi.com)\*\*Yes[fastFOREX.io](https://www.fastforex.io)USD (free), \* (paid)\*No[exchangerate.host](https://www.exchangerate.host)\*\*YesArray\*\*YesCredits
-------

[](#credits)

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

License
-------

[](#license)

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

###  Health Score

69

—

FairBetter than 100% of packages

Maintenance86

Actively maintained with recent releases

Popularity60

Solid adoption and visibility

Community28

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 76.2% 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 ~231 days

Recently: every ~645 days

Total

18

Last Release

70d ago

Major Versions

0.x-dev → 1.0.02016-10-09

1.x-dev → 2.0.02019-02-12

PHP version history (5 changes)v0.1.0PHP &gt;=5.5.9

1.0.0PHP ^5.5|^7.0

2.0.0PHP ^7.1.3

2.3.0PHP ^7.1.3 || ^8.0

2.4.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 (80 commits)")[![alies-dev](https://avatars.githubusercontent.com/u/5278175?v=4)](https://github.com/alies-dev "alies-dev (13 commits)")[![kslimani](https://avatars.githubusercontent.com/u/1758996?v=4)](https://github.com/kslimani "kslimani (7 commits)")[![denlapaev](https://avatars.githubusercontent.com/u/3096564?v=4)](https://github.com/denlapaev "denlapaev (1 commits)")[![arjanwestdorp](https://avatars.githubusercontent.com/u/7716654?v=4)](https://github.com/arjanwestdorp "arjanwestdorp (1 commits)")[![mohammad6006](https://avatars.githubusercontent.com/u/553379?v=4)](https://github.com/mohammad6006 "mohammad6006 (1 commits)")[![Naoray](https://avatars.githubusercontent.com/u/10154100?v=4)](https://github.com/Naoray "Naoray (1 commits)")[![simplenotezy](https://avatars.githubusercontent.com/u/3786627?v=4)](https://github.com/simplenotezy "simplenotezy (1 commits)")

---

Tags

currencycurrency-convertercurrency-exchange-ratescurrency-ratesexchange-rateslaravellumenphplaravelmoneycurrencylumenconversionRateexchange rates

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[florianv/swap

Exchange rates library for PHP

1.3k6.4M16](/packages/florianv-swap)[florianv/exchanger

Currency exchange rates framework for PHP

1874.7M15](/packages/florianv-exchanger)[torann/currency

This provides Laravel with currency functions such as currency formatting and conversion using up-to-date exchange rates.

4081.1M6](/packages/torann-currency)[florianv/swap-bundle

Integrates the Swap library with Symfony

62416.1k1](/packages/florianv-swap-bundle)[danielme85/laravel-cconverter

Laravel 5 plug-in for currency conversion

42101.1k](/packages/danielme85-laravel-cconverter)

PHPackages © 2026

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