PHPackages                             bishwajitcadhikary/laravel-currency-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. [API Development](/categories/api)
4. /
5. bishwajitcadhikary/laravel-currency-exchange

ActiveLibrary[API Development](/categories/api)

bishwajitcadhikary/laravel-currency-exchange
============================================

Check Exchange Rates for any currency in Laravel.

v1.0.2(1y ago)012[1 PRs](https://github.com/bishwajitcadhikary/laravel-currency-exchange/pulls)MITPHPPHP ^8.2CI passing

Since Feb 12Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/bishwajitcadhikary/laravel-currency-exchange)[ Packagist](https://packagist.org/packages/bishwajitcadhikary/laravel-currency-exchange)[ Docs](https://github.com/worksome/exchange)[ GitHub Sponsors](https://github.com/worksome)[ RSS](/packages/bishwajitcadhikary-laravel-currency-exchange/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (10)Versions (5)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.

### Original Author

[](#original-author)

[Luke Downing (Worksome)](https://github.com/worksome/exchange)

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

[](#installation)

You can install the package via composer.

```
composer require bishwajitcadhikary/currency-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.

```
$rates = $exchangeRates->getRates(); // ['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 published by the European Central Bank, which can be used without an API key.

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

With that task completed, you're ready to start using [frankfurter.dev](https://frankfurter.app) 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

33

—

LowBetter than 75% of packages

Maintenance60

Regular maintenance activity

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

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

Total

3

Last Release

404d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/05f9a72ab9f1685e2d1e829714d6c3470ea38acc3bdf3b6608ac5edb4997b835?d=identicon)[bishwajitcadhikary](/maintainers/bishwajitcadhikary)

---

Top Contributors

[![bishwajitcadhikary](https://avatars.githubusercontent.com/u/55208330?v=4)](https://github.com/bishwajitcadhikary "bishwajitcadhikary (5 commits)")

---

Tags

laravelexchangeworksome

###  Code Quality

TestsPest

Static AnalysisPHPStan

### Embed Badge

![Health badge](/badges/bishwajitcadhikary-laravel-currency-exchange/health.svg)

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

###  Alternatives

[worksome/envy

Automatically keep your .env files in sync.

6871.8M](/packages/worksome-envy)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)[combindma/laravel-facebook-pixel

Meta pixel integration for Laravel

4956.9k](/packages/combindma-laravel-facebook-pixel)[stechstudio/laravel-hubspot

A Laravel SDK for the HubSpot CRM Api

2971.0k](/packages/stechstudio-laravel-hubspot)

PHPackages © 2026

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