PHPackages                             worksome/exchange - 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. worksome/exchange

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

worksome/exchange
=================

Check Exchange Rates for any currency in Laravel.

v3.0.0(3w ago)124603.0k↑32.7%11[1 PRs](https://github.com/worksome/exchange/pulls)MITPHPPHP ^8.4CI passing

Since Feb 23Pushed 3w ago8 watchersCompare

[ Source](https://github.com/worksome/exchange)[ Packagist](https://packagist.org/packages/worksome/exchange)[ Docs](https://github.com/worksome/exchange)[ GitHub Sponsors](https://github.com/worksome)[ RSS](/packages/worksome-exchange/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (40)Versions (27)Used By (0)

Exchange
========

[](#exchange)

Check exchange rates for any currency in Laravel

[![Latest Version on Packagist](https://camo.githubusercontent.com/295f8dfd972eab896a8b201fe74181b3b6f778443e910de8ebc137409e304c70/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776f726b736f6d652f65786368616e67652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/worksome/exchange)[![GitHub Tests Action Status](https://camo.githubusercontent.com/497ad19daa5ad843db8edaea6066ffc34fc88cd078add2e2acb2952aa9a296c9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f776f726b736f6d652f65786368616e67652f74657374732e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265266c6162656c3d5465737473)](https://github.com/worksome/exchange/actions?query=workflow%3ATests+branch%3Amain)[![GitHub Static Analysis Action Status](https://camo.githubusercontent.com/3e89d474a54f640ab7b04efdd5c99f20ce1b18f7320beffc0edeb30913d3795c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f776f726b736f6d652f65786368616e67652f7374617469632e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265266c6162656c3d537461746963253230416e616c79736973)](https://github.com/worksome/exchange/actions?query=workflow%3A%22Static%20Analysis%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/d3010ee565a6a95b38dc483e1e392f941abc52fc73f96aa72571c0ebfecf3702/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f776f726b736f6d652f65786368616e67652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/worksome/exchange)

If your app supports multi-currency, you'll no doubt need to check exchange rates. There are many third party services to accomplish this, but why bother reinventing the wheel when we've done all the hard work for you?

Exchange provides an abstraction layer for exchange rate APIs, with a full suite of tools for caching, testing and local development.

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

[](#installation)

You can install the package via composer.

```
composer require worksome/exchange
```

To install the exchange config file, you can use our `install` artisan command!

```
php artisan exchange:install
```

Exchange is now installed!

Usage
-----

[](#usage)

Exchange ships with a number of useful drivers for retrieving exchange rates. The default is `exchange_rate`, which is a free service, but you're welcome to change that to suit you app's requirements.

The driver can be set using the `EXCHANGE_DRIVER` environment variable. Supported values are: `null`, `fixer`, `exchange_rate` and `cache`. Let's take a look at each of the options available.

### Null

[](#null)

You can start using Exchange locally with the `null` driver. This will simply return `1.0` for every exchange rate, which is generally fine for local development.

```
use Worksome\Exchange\Facades\Exchange;

$exchangeRates = Exchange::rates('USD', ['GBP', 'EUR']);
```

In the example above, we are retrieving exchange rates for GBP and EUR based on USD. The `rates` method will return a `Worksome\Exchange\Support\Rates` object, which includes the base currency, retrieved rates and the time of retrieval. Retrieved rates are an `array` with currency codes as keys and exchange rates as values.

```
/** @var \Worksome\Exchange\Support\Rates $exchangeRates */
$rates = $exchangeRates->rates; // ['GBP' => 1.0, 'EUR' => 1.0]
```

### Fixer

[](#fixer)

Of course, the `null` driver isn't very useful when you want actual exchange rates. For this, you should use the `fixer` driver.

In your `exchange.php` config file, set `default` to `fixer`, or set `EXCHANGE_DRIVER` to `fixer` in your `.env` file. Next, you'll need an access key from . Set `FIXER_ACCESS_KEY` to your provided access key from Fixer.

That's it! Fixer is now configured as the default driver and running `Exchange::rates()` again will make a request to Fixer for up-to-date exchange rates.

### ExchangeRate.host

[](#exchangeratehost)

[exchangerate.host](https://exchangerate.host) is an alternative to Fixer with an identical API spec.

In your `exchange.php` config file, set `default` to `exchange_rate`, or set `EXCHANGE_DRIVER` to `exchange_rate` in your `.env` file. Set `EXCHANGE_RATE_ACCESS_KEY` to your provided access key from exchangerate.host.

With that task completed, you're ready to start using [exchangerate.host](https://exchangerate.host) for retrieving up-to-date exchange rates.

### Currency.GetGeoApi.com

[](#currencygetgeoapicom)

[Currency.GetGeoApi.com](https://currency.getgeoapi.com) is an alternative option you can use with a free quota.

In your `exchange.php` config file, set `default` to `currency_geo`, or set `EXCHANGE_DRIVER` to `currency_geo` in your `.env` file. Set `CURRENCY_GEO_ACCESS_KEY` to your provided access key from currency.getgeoapi.com.

With that task completed, you're ready to start using [Currency.GetGeoApi.com](https://currency.getgeoapi.com) for retrieving up-to-date exchange rates.

### Frankfurter.dev

[](#frankfurterdev)

[frankfurter.dev](https://frankfurter.dev) is an open-source API for current and historical foreign exchange rates, which can be used without an API key.

The driver targets the v2 API, which covers a much larger currency set than the ECB-only v1 (for example `AED` and `MAD`).

In your `exchange.php` config file, set `default` to `frankfurter`, or set `EXCHANGE_DRIVER` to `frankfurter` in your `.env` file.

If you are self-hosting Frankfurter or need to use a different endpoint, you can set `FRANKFURTER_BASE_URL` in your `.env` file. It defaults to `https://api.frankfurter.dev/v2`.

Note

Prior to v3 of this package, the `frankfurter` driver targeted the v1 API. If you need to keep using the v1 API, stay on v2 of this package.

With that task completed, you're ready to start using [frankfurter.dev](https://frankfurter.dev) for retrieving up-to-date exchange rates.

### Cache

[](#cache)

It's unlikely that you want to make a request to a third party service every time you call `Exchange::rates()`. To remedy this, we provide a cache decorator that can be used to store retrieved exchange rates for a specified period (24 hours by default).

In your `exchange.php` config file, set `default` to `cache`, or set `EXCHANGE_DRIVER` to `cache` in your `.env` file. You'll also want to pick a strategy under `services.cache.strategy`. By default, this will be `fixer`, but you are free to change that. The strategy is the service that will be used to perform the exchange rate lookup when nothing is found in the cache.

There is also the option to override the `ttl` (how many seconds rates are cached for), `key` for your cached rates, and the `store`.

Artisan
-------

[](#artisan)

We provide an Artisan command for you to check Exchange is working correctly in your project.

```
php artisan exchange:rates USD GBP EUR
```

In the example above, exchange rates will be retrieved and displayed in the console from a base of USD to GBP and EUR respectively. You can add as many currencies as you'd like to the command.

[![CleanShot 2022-02-23 at 13 10 55@2x](https://user-images.githubusercontent.com/12202279/155325937-70c296d1-33be-484d-bcd1-bee3085dc592.png)](https://user-images.githubusercontent.com/12202279/155325937-70c296d1-33be-484d-bcd1-bee3085dc592.png)

Testing
-------

[](#testing)

To help you write tests using Exchange, we provide a fake implementation via the `Exchange::fake()` method.

```
it('retrieves exchange rates', function () {
    Exchange::fake(['GBP' => 1.25, 'USD' => 1.105]);

    $this->get(route('my-app-route'))
        ->assertOk();

    Exchange::assertRetrievedRates();
});
```

The `assertRetrievedRates` method will cause your test to fail if no exchange rates were ever retrieved.

Internally, Exchange prides itself on a thorough test suite written in Pest, strict static analysis, and a very high level of code coverage. You may run these tests yourself by cloning the project and running our test script:

```
composer test
```

Changelog
---------

[](#changelog)

Please see [GitHub Releases](https://github.com/worksome/exchange/releases) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Luke Downing](https://github.com/lukeraymonddowning)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

66

—

FairBetter than 99% of packages

Maintenance95

Actively maintained with recent releases

Popularity53

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~104 days

Recently: every ~25 days

Total

16

Last Release

23d ago

Major Versions

v0.2.0 → v1.0.02022-03-03

v1.4.0 → v2.0.02024-03-22

v2.5.0 → v3.0.02026-06-10

PHP version history (3 changes)v0.1.0PHP ^8.0 || ^8.1

v1.3.0PHP ^8.2

v2.3.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/139db346fa173a79481af05b0455e2e8ad7d2ab594c7f53bde3522a3dfeeaf25?d=identicon)[96downlu](/maintainers/96downlu)

---

Top Contributors

[![lukeraymonddowning](https://avatars.githubusercontent.com/u/12202279?v=4)](https://github.com/lukeraymonddowning "lukeraymonddowning (43 commits)")[![owenvoke](https://avatars.githubusercontent.com/u/1899334?v=4)](https://github.com/owenvoke "owenvoke (36 commits)")[![Saifallak](https://avatars.githubusercontent.com/u/6053156?v=4)](https://github.com/Saifallak "Saifallak (12 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![olivernybroe](https://avatars.githubusercontent.com/u/5870441?v=4)](https://github.com/olivernybroe "olivernybroe (5 commits)")[![ju5t](https://avatars.githubusercontent.com/u/3635751?v=4)](https://github.com/ju5t "ju5t (3 commits)")[![julesjanssen](https://avatars.githubusercontent.com/u/492036?v=4)](https://github.com/julesjanssen "julesjanssen (3 commits)")[![xiCO2k](https://avatars.githubusercontent.com/u/823088?v=4)](https://github.com/xiCO2k "xiCO2k (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")[![daannet](https://avatars.githubusercontent.com/u/3153179?v=4)](https://github.com/daannet "daannet (1 commits)")

---

Tags

laravelexchangeworksome

###  Code Quality

TestsPest

Static AnalysisPHPStan

### Embed Badge

![Health badge](/badges/worksome-exchange/health.svg)

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

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M165](/packages/spatie-laravel-health)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329530.5k29](/packages/codewithdennis-filament-select-tree)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

199.4k](/packages/tarfin-labs-event-machine)[tapp/filament-form-builder

User facing form builder using Filament components

132.4k3](/packages/tapp-filament-form-builder)

PHPackages © 2026

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