PHPackages                             orkhanahmadov/laravel-currencylayer - 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. orkhanahmadov/laravel-currencylayer

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

orkhanahmadov/laravel-currencylayer
===================================

Laravel package for currencylayer.com

1.4.0(6y ago)22643MITPHPPHP ^7.1

Since Sep 16Pushed 5y ago1 watchersCompare

[ Source](https://github.com/orkhanahmadov/laravel-currencylayer)[ Packagist](https://packagist.org/packages/orkhanahmadov/laravel-currencylayer)[ Docs](https://github.com/orkhanahmadov/laravel-currencylayer)[ RSS](/packages/orkhanahmadov-laravel-currencylayer/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (8)Versions (6)Used By (0)

💱 Laravel package for [currencylayer.com](https://currencylayer.com)
====================================================================

[](#currency_exchange-laravel-package-for-currencylayercom)

[![Latest Stable Version](https://camo.githubusercontent.com/447f208c2202e48e3e8d3557ad1e0b56dfedd036a61be57e447e26bf5fa246bd/68747470733a2f2f706f7365722e707567782e6f72672f6f726b68616e61686d61646f762f6c61726176656c2d63757272656e63796c617965722f762f737461626c65)](https://packagist.org/packages/orkhanahmadov/laravel-currencylayer)[![Latest Unstable Version](https://camo.githubusercontent.com/6f87afe8796eea45362687612357f47a9be995f18fbbb403d35801f36332e36e/68747470733a2f2f706f7365722e707567782e6f72672f6f726b68616e61686d61646f762f6c61726176656c2d63757272656e63796c617965722f762f756e737461626c65)](https://packagist.org/packages/orkhanahmadov/laravel-currencylayer)[![Total Downloads](https://camo.githubusercontent.com/5cdcb5812bda8b6dea77c9a5fcdfd91e8ece17945085cb8569ae93f041ce81ac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f726b68616e61686d61646f762f6c61726176656c2d63757272656e63796c61796572)](https://packagist.org/packages/orkhanahmadov/laravel-currencylayer)[![License](https://camo.githubusercontent.com/abc2abe13af2fb359ee2a2992f609233f683bc17b07163cca7cddd45673b464b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6f726b68616e61686d61646f762f6c61726176656c2d63757272656e63796c617965722e737667)](https://github.com/orkhanahmadov/laravel-currencylayer/blob/master/LICENSE.md)

[![Build Status](https://camo.githubusercontent.com/ab21fc9c7c5219a0dec2e55c0d76daf6d11764da1fb401b7d46a59e7d641bf7c/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6f726b68616e61686d61646f762f6c61726176656c2d63757272656e63796c617965722e737667)](https://travis-ci.org/orkhanahmadov/laravel-currencylayer)[![Test Coverage](https://camo.githubusercontent.com/add10369064ba8287bb812493410a7f4885fe20825a69f5ee85a85f0b240cc38/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f38356238343035313734613631396539303665312f746573745f636f766572616765)](https://codeclimate.com/github/orkhanahmadov/laravel-currencylayer/test_coverage)[![Maintainability](https://camo.githubusercontent.com/b8772565a432d9c2ebd12e15d72f8c6fd79dd970caa27bbd0f449745652359bf/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f38356238343035313734613631396539303665312f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/orkhanahmadov/laravel-currencylayer/maintainability)[![Quality Score](https://camo.githubusercontent.com/2d448c1fa4fc4086e7b372b03784a878f09ae48b24c6843375bc69ed6bde3043/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6f726b68616e61686d61646f762f6c61726176656c2d63757272656e63796c617965722e737667)](https://scrutinizer-ci.com/g/orkhanahmadov/laravel-currencylayer)[![StyleCI](https://camo.githubusercontent.com/3f0751b317cb24e9a8c5cc265566bb6fa76035ecd3364df6a9573d1e0e1f3616/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3230383132363334302f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/208126340)

Simple Laravel package for integrating with currencylayer.com currency rates.

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

[](#requirements)

- PHP 7.1 or higher
- Laravel 5.8 or higher

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

[](#installation)

You can install the package via composer:

```
composer require orkhanahmadov/laravel-currencylayer
```

Publish package migration and config files:

```
php artisan vendor:publish --provider="Orkhanahmadov\LaravelCurrencylayer\LaravelCurrencylayerServiceProvider"
```

Set your currencylayer.com access key in `.env` file:

```
CURRENCYLAYER_ACCESS_KEY=your-key-here
```

You can find your access key in [Currencylayer Dashboard](https://currencylayer.com/dashboard).

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

[](#configuration)

After publishing configuration file it will be available in `config` directory as `currencylayer.php`

It has following settings:

- `access_key` - currencylayer.com access key, by default uses value from `.env` file
- `https_connection` - if set to `true` all calls to currencylayer API endpoint will be over HTTPS, instead of default HTTP

Usage
-----

[](#usage)

You can type-hint `Orkhanahmadov\LaravelCurrencylayer\Contracts\CurrencyService` to inject it from container:

```
use Orkhanahmadov\LaravelCurrencylayer\Contracts\CurrencyService;

class CurrencyController
{
    public function index(CurrencyService $currencyService)
    {
        $currencyService->live('USD', 'EUR');
    }
}
```

Anywhere outside container you can create instance of the service with `app()` helper:

```
$currencyService = app('currencylayer');
$currencyService->live('USD', 'EUR');
```

You can also use provided facade:

```
\Currencylayer::live('USD', 'EUR');
```

### Available methods

[](#available-methods)

All methods save rates to database table when fetched.

#### `live()`

[](#live)

Method fetches live rates from currencylayer.com

```
$currencyService->live('USD', 'EUR');
```

First argument is source currency, second argument is converted currency. You can also pass instance of `Orkhanahmadov\LaravelCurrencylayer\Models\Currency` as a source currency.

```
use Orkhanahmadov\LaravelCurrencylayer\Models\Currency;

$usd = Currency::where('code', 'USD')->first();
$currencyService->live($usd, 'EUR');
```

To get live rates for multiple currencies, pass multiple currency codes:

```
$currencyService->live('USD', 'EUR', 'CHF', 'BTC', 'RUB');
// or
$currencyService->live('USD', ['EUR', 'CHF', 'BTC', 'RUB']);
```

#### `rate()`

[](#rate)

Method fetches rates for given date from currencylayer.com

```
$currencyService->rate('USD', '2019-01-25', 'EUR');
```

First argument is source currency, second argument is date, third argument is converted currency. You can also pass instance of `Orkhanahmadov\LaravelCurrencylayer\Models\Currency` as a source currency argument and instance of `Carbon\Carbon` as a date argument.

```
use Carbon\Carbon;
use Orkhanahmadov\LaravelCurrencylayer\Models\Currency;

$usd = Currency::where('code', 'USD')->first();
$today = Carbon::today();
$currencyService->rate($usd, $today, 'EUR');
```

To get rates for multiple currencies, pass multiple currency codes:

```
$currencyService->rate('USD', '2019-01-25', 'EUR', 'CHF', 'BTC', 'RUB');
// or
$currencyService->rate('USD', '2019-01-25', ['EUR', 'CHF', 'BTC', 'RUB']);
```

### Commands

[](#commands)

Package comes with 2 commands:

`php artisan currencylayer:live` - fetches live rates and outputs the values. First argument is source currency, second and next arguments are target currencies:

```
php artisan currencylayer:live USD EUR CHF
```

This will fetch live rates for USD to EUR and USD to CHF.

`php artisan currencylayer:rate` - fetches rates for given date and outputs the values. First argument is source currency, second argument is date, third and next arguments are target currencies:

```
php artisan currencylayer:rate USD 2019-01-25 EUR CHF
```

This will fetch rates for 2019-01-25 for USD to EUR and USD to CHF.

### Models

[](#models)

Package comes with 2 database models:

- `Orkhanahmadov\LaravelCurrencylayer\Models\Currency` - stores each fetched currency codes
- `Orkhanahmadov\LaravelCurrencylayer\Models\Rate` - stores rate for each currency exchange based on timestamp

`Currency` model has `rateFor()` method you can use to get currency rate. First argument is target currency code or can be instance of `Currency`.

```
use Orkhanahmadov\LaravelCurrencylayer\Models\Currency;

$usd = Currency::where('code', 'USD')->first();
$rate = $usd->rateFor('EUR');
// or
$eur = Currency::where('code', 'EUR')->first();
$rate = $usd->rateFor($eur);
```

This will fetch latest USD to EUR rate.

You can also pass date or `Carbon\Carbon` instance as a second argument to get rates for that date:

```
use Carbon\Carbon;
use Orkhanahmadov\LaravelCurrencylayer\Models\Currency;

$usd = Currency::where('code', 'USD')->first();
$rate = $usd->rateFor('EUR', '2019-01-25');
// or
$today = Carbon::today();
$rate = $usd->rateFor('EUR', $today);
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Orkhan Ahmadov](https://github.com/orkhanahmadov)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

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

Total

5

Last Release

2469d ago

### Community

Maintainers

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

---

Top Contributors

[![orkhanahmadov](https://avatars.githubusercontent.com/u/7041590?v=4)](https://github.com/orkhanahmadov "orkhanahmadov (75 commits)")

---

Tags

currencycurrencylayerlaravellaravelcurrencyorkhanahmadovcurrencylayerlaravel-currencylayer

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/orkhanahmadov-laravel-currencylayer/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.7k](/packages/larastan-larastan)[laravel/ai

The official AI SDK for Laravel.

1.0k2.1M165](/packages/laravel-ai)[illuminate/queue

The Illuminate Queue package.

20432.2M1.5k](/packages/illuminate-queue)[flarum/core

Delightfully simple forum software.

201.4M2.2k](/packages/flarum-core)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)

PHPackages © 2026

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