PHPackages                             finller/laravel-forex - 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. finller/laravel-forex

Abandoned → [elegantly/laravel-forex](/?search=elegantly%2Flaravel-forex)Library[Utility &amp; Helpers](/categories/utility)

finller/laravel-forex
=====================

Forex for Laravel

v4.0.3(1mo ago)42.4kMITPHPPHP ^8.3CI passing

Since Mar 3Pushed 1mo agoCompare

[ Source](https://github.com/ElegantEngineeringTech/laravel-forex)[ Packagist](https://packagist.org/packages/finller/laravel-forex)[ Docs](https://github.com/ElegantEngineeringTech/laravel-forex)[ GitHub Sponsors](https://github.com/ElegantEngineeringTech)[ RSS](/packages/finller-laravel-forex/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (10)Dependencies (85)Versions (30)Used By (0)

Laravel Forex
=============

[](#laravel-forex)

[![Latest Version on Packagist](https://camo.githubusercontent.com/639aa6e1917351c8dac2f6c9ba933af7f378da3f479a35a9267730ec5bf7a98e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656c6567616e746c792f6c61726176656c2d666f7265782e737667)](https://packagist.org/packages/elegantly/laravel-forex)[![Total Downloads](https://camo.githubusercontent.com/b0b2f276486b0dafc5b1fb00f900efec1272ac26dc04d6eb3b674a15615d7eaa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656c6567616e746c792f6c61726176656c2d666f7265782e737667)](https://packagist.org/packages/elegantly/laravel-forex)[![Tests](https://github.com/ElegantEngineeringTech/laravel-forex/actions/workflows/run-tests.yml/badge.svg)](https://github.com/ElegantEngineeringTech/laravel-forex/actions/workflows/run-tests.yml)[![Laravel Pint](https://github.com/ElegantEngineeringTech/laravel-forex/actions/workflows/pint.yml/badge.svg)](https://github.com/ElegantEngineeringTech/laravel-forex/actions/workflows/pint.yml)[![PHPStan](https://github.com/ElegantEngineeringTech/laravel-forex/actions/workflows/phpstan.yml/badge.svg)](https://github.com/ElegantEngineeringTech/laravel-forex/actions/workflows/phpstan.yml)

**Laravel Forex** is a simple and flexible package for retrieving the latest and historical foreign exchange rates in your Laravel application.

By default, it uses the free tier from [exchangerate-api.com](https://www.exchangerate-api.com/), but you can easily configure it to use any other Forex provider.

---

Contents
--------

[](#contents)

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Latest Rates](#latest-rates)
    - [Historical Rates](#historical-rates)
    - [Converting Money](#converting-money)
    - [Refreshing Rates](#refreshing-rates)
- [Providers](#providers)
    - [ExchangeRate-Api.com](#exchangerate-apicom)
    - [Custom Client](#custom-client)
- [Caching &amp; Rate Limiting](#caching--rate-limiting)
- [Testing](#testing)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [Security](#security)
- [Credits](#credits)
- [License](#license)

---

Features
--------

[](#features)

- Retrieve latest exchange rates for any base currency.
- Retrieve historical exchange rates for a specific date.
- Convert `Money` instances between currencies with high precision using [`brick/money`](https://github.com/brick/money).
- Built-in caching and optional rate limiting to keep API usage under control.
- Swap the default provider with a custom implementation via a simple interface.

---

Requirements
------------

[](#requirements)

- PHP `^8.3`
- Laravel `^13.0`

---

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

[](#installation)

Install the package via Composer:

```
composer require elegantly/laravel-forex
```

Publish the configuration file:

```
php artisan vendor:publish --tag="forex-config"
```

---

Configuration
-------------

[](#configuration)

The published configuration file lives at `config/forex.php`:

```
use Brick\Math\RoundingMode;
use Elegantly\Forex\Integrations\ExchangeRateApiFree\ExchangeRateApiFreeConnector;

return [

    /**
     * Rounding mode used when converting money.
     */
    'rounding_mode' => RoundingMode::HalfUp,

    'cache' => [
        'enabled' => true,
        'driver' => env('FOREX_CACHE_DRIVER', env('CACHE_STORE', env('CACHE_DRIVER', 'file'))),
        'expiry_seconds' => 86_400, // 1 day
    ],

    'rate_limit' => [
        'enabled' => false,
        'driver' => env('FOREX_RATE_LIMIT_DRIVER', env('CACHE_STORE', env('CACHE_DRIVER', 'file'))),
        'every_seconds' => 3_600, // 1 hour
    ],

    'client' => ExchangeRateApiFreeConnector::class,

    'clients' => [
        'exchange-rate-api' => [
            'token' => env('EXCHANGE_RATE_API_TOKEN'),
        ],
    ],

];
```

### Environment Variables

[](#environment-variables)

VariableDescription`EXCHANGE_RATE_API_TOKEN`Your API token when using the paid `exchangerate-api.com` connector.`FOREX_CACHE_DRIVER`The cache store used for Forex responses.`FOREX_RATE_LIMIT_DRIVER`The cache store used for rate limiting.---

Usage
-----

[](#usage)

All public methods are available through the `Forex` facade:

```
use Elegantly\Forex\Facades\Forex;
```

### Latest Rates

[](#latest-rates)

Fetch the latest rates for a given base currency:

```
$rates = Forex::latest('USD');

$usdToEur = $rates['EUR'];
```

### Historical Rates

[](#historical-rates)

Fetch historical rates for a specific date:

```
use Carbon\Carbon;

$rates = Forex::rates(Carbon::create(2022, 4, 25), 'USD');

$usdToEur = $rates['EUR'];
```

### Converting Money

[](#converting-money)

Convert a `Money` instance from one currency to another:

```
use Brick\Math\RoundingMode;
use Brick\Money\Money;
use Elegantly\Forex\Facades\Forex;

$convertedMoney = Forex::convert(
    money: Money::of(100, 'USD'),
    currency: 'EUR',
);

$convertedMoney->__toString(); // (EUR) 88.84
```

You can also convert against historical rates and override the rounding mode:

```
use Carbon\Carbon;

$convertedMoney = Forex::convert(
    money: Money::of(100, 'USD'),
    currency: 'EUR',
    roundingMode: RoundingMode::Down,
    date: Carbon::create(2022, 4, 25),
);
```

### Refreshing Rates

[](#refreshing-rates)

By default, rates are cached according to your configuration. To bypass the cache and fetch fresh data:

```
// Refresh latest rates
Forex::refreshLatest('USD');

// Refresh historical rates
Forex::refreshRates(Carbon::create(2022, 4, 25), 'USD');
```

---

Providers
---------

[](#providers)

### ExchangeRate-Api.com

[](#exchangerate-apicom)

The package ships with two ready-to-use connectors for [exchangerate-api.com](https://www.exchangerate-api.com/):

- `ExchangeRateApiFreeConnector` — uses the free public endpoint. Rates are updated once a day and historical data is not supported.
- `ExchangeRateApiConnector` — uses the authenticated v6 API. Requires a token and supports historical rates.

To use the paid connector, update your config:

```
use Elegantly\Forex\Integrations\ExchangeRateApi\ExchangeRateApiConnector;

'client' => ExchangeRateApiConnector::class,
```

And add your token to `.env`:

```
EXCHANGE_RATE_API_TOKEN=your-api-token
```

### Custom Client

[](#custom-client)

Want to use a different provider? Implement the `ForexClient` interface:

```
use Carbon\CarbonInterface;
use Elegantly\Forex\ForexClient;

class MyCustomForexClient implements ForexClient
{
    public function latest(string $currency): array
    {
        // Return an associative array of currency code => rate
    }

    public function rates(CarbonInterface $date, string $currency): array
    {
        // Return historical rates for the given date
    }
}
```

Then set it as the active client:

```
'client' => \App\Services\MyCustomForexClient::class,
```

---

Caching &amp; Rate Limiting
---------------------------

[](#caching--rate-limiting)

The package uses Saloon's cache and rate-limit plugins to reduce API calls and avoid hitting provider limits.

- **Caching** is enabled by default and stores responses for the configured `expiry_seconds`.
- **Rate limiting** is disabled by default. Enable it to throttle requests to one per `every_seconds` interval.

Both features use the cache store configured in `forex.php`.

---

Testing
-------

[](#testing)

Run the test suite with:

```
composer test
```

Run the static analysis suite with:

```
composer analyse
```

Format the code with:

```
composer format
```

---

Changelog
---------

[](#changelog)

See the [CHANGELOG](CHANGELOG.md) for details on recent updates.

---

Contributing
------------

[](#contributing)

Contributions are welcome! Please read the [CONTRIBUTING](CONTRIBUTING.md) guide for details.

---

Security
--------

[](#security)

If you discover any security-related issues, please refer to our [security policy](../../security/policy).

---

Credits
-------

[](#credits)

- [Quentin Gabriele](https://github.com/QuentinGab)
- [All Contributors](../../contributors)

---

License
-------

[](#license)

This package is open-source software licensed under the [MIT license](LICENSE.md).

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance93

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 74% 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 ~33 days

Recently: every ~18 days

Total

27

Last Release

34d ago

Major Versions

v1.2.0 → v2.0.02025-04-16

v2.5.1 → v3.0.02026-05-02

v3.0.0 → v4.0.02026-05-02

PHP version history (2 changes)v1.0.0PHP ^8.1

v4.0.1PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/d769563728757858e249f266ac2555f28db5640124df92821ed17d93ee76fc7b?d=identicon)[QuentinGab](/maintainers/QuentinGab)

---

Top Contributors

[![QuentinGab](https://avatars.githubusercontent.com/u/40128136?v=4)](https://github.com/QuentinGab "QuentinGab (77 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (18 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (9 commits)")

---

Tags

exchange-ratesforexlaravellaravel-packagelaravelElegantlylaravel-forex

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/finller-laravel-forex/health.svg)

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

###  Alternatives

[codebar-ag/laravel-docuware

DocuWare integration with Laravel

1125.1k](/packages/codebar-ag-laravel-docuware)[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.

329575.9k35](/packages/codewithdennis-filament-select-tree)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3915.5k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

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