PHPackages                             danielme85/laravel-cconverter - 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. danielme85/laravel-cconverter

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

danielme85/laravel-cconverter
=============================

Laravel 5 plug-in for currency conversion

v0.3.0(6y ago)42102.7k↑587.5%10[4 issues](https://github.com/danielme85/Laravel-CConverter/issues)MITPHPPHP &gt;=7.1

Since Aug 22Pushed 5y ago1 watchersCompare

[ Source](https://github.com/danielme85/Laravel-CConverter)[ Packagist](https://packagist.org/packages/danielme85/laravel-cconverter)[ RSS](/packages/danielme85-laravel-cconverter/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (4)Versions (10)Used By (0)

Laravel Currency Converter
==========================

[](#laravel-currency-converter)

[![GitHub](https://camo.githubusercontent.com/7123c32787e013be5a8a13598ad01f562754637ed6141e89b02e85bf16d3e63e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6173686170652f6170697374617475732e7376673f7374796c653d666c61742d737175617265)](https://github.com/danielme85/laravel-cconverter)[![PHP from Packagist](https://camo.githubusercontent.com/57e7e1aef78cd1d1cf4c405234558d83c527c6e3c418f7d0dc60767eb2f7b17f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f64616e69656c6d6538352f6c61726176656c2d63636f6e7665727465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/danielme85/laravel-cconverter)[![GitHub release](https://camo.githubusercontent.com/5eab4827e734aa9d80fb4f83e24f294f9c743bd4869dc5a8022509c4f73d4348/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f64616e69656c6d6538352f6c61726176656c2d63636f6e7665727465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/danielme85/laravel-cconverter)[![GitHub tag](https://camo.githubusercontent.com/eded37c99d24e806eb1f462930332c4b7f314ab2e0beaeeb2357e506afdd8f13/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f64616e69656c6d6538352f6c61726176656c2d63636f6e7665727465722e7376673f7374796c653d666c61742d737175617265)](https://github.com/danielme85/laravel-cconverter)[![Travis (.org)](https://camo.githubusercontent.com/2e84e36c9f979048708f49949c3392a2ee2c9eb6c2be15442761ff291bb4474d/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f64616e69656c6d6538352f6c61726176656c2d63636f6e7665727465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/danielme85/laravel-cconverter)[![Codecov](https://camo.githubusercontent.com/e05f00f22fa58e2406936ecadc8ecb9d1aa0dc25bb0b0993bbe37aaa3ecb585e/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f64616e69656c6d6538352f6c61726176656c2d63636f6e7665727465722e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/danielme85/laravel-cconverter)

A simple currency conversion plug-in for Laravel 5.5+ 💵
Example usage: [](https://danielmellum.com/projects/currency-converter)

Version testing and requirements

VersionTested withdev-masterLaravel 6.0v0.3.\*Laravel 6.0v0.2.\*Laravel 5.6v0.1.\*Laravel 5.5v0.0.7Laravel 5.4If you are having composer requirement issues using the latest release and Laravel &lt; v5.4, try the v0.0.7 release.

Please note:

- The European Central Bank does not require any user account and is therefore set as the default 'api-source', however the number of available currencies are somewhat limited compared to the other commercial sources (37). In my experience this source is also unpredictable, and might give an empty response.
- All the other data providers are commercial and require a user account. They all have a free tier of 1000 requests per month, let's say you theoretically cache results for 60 min and you should be covered with some margin for errors 👍 Coincidentally Cache is enabled per default and set to 60 min. Now in theory one should perhaps make a simple Eloquent Model with the columns: date, from, to, rate or something similar, and then store the historical results. Please note that depending on usage this might go against the user agreements on the commercial data providers. 🤫 🙈

### Installation

[](#installation)

```
composer require danielme85/laravel-cconverter

```

### Configuration

[](#configuration)

You can publish this vendor config file if you would like to make changes to the default config.

```
php artisan vendor:publish --provider="danielme85\CConverter\CConverterServiceProvider"

```

All config variables can also be changed in your local .env file:

```
CC_API_SOURCE=eurocentralbank
CC_USE_SSL=true
CC_FIXERIO_ACCESS_KEY=
CC_OPENEXCHANGE_APP_ID=
CC_CURRENCYLAYER_ACCESS_KEY=
CC_ENABLE_LOG=false
CC_ENABLE_CACHE=true
CC_CACHE_TIMEOUT=60

```

### Usage

[](#usage)

There are static class "shortcuts" to convert or get one-time Currency series.

```
//To convert a value
$valueNOK = Currency::conv($from = 'USD', $to = 'NOK', $value = 10, $decimals = 2);

//To convert a value based on historical data
$valueNOK = Currency::conv($from = 'USD', $to = 'NOK', $value = 10, $decimals = 2, $date = '2018-12-24');

//to get an array of all the rates associated to a base currency.
$rates = Currency::rates(); //defaults to USD

$rates = Currency::rates('NOK');

//Get historical rates
$rates = Currency::rates('NOK', '2018-12-24');
```

#### Working with multiple values

[](#working-with-multiple-values)

I would highly recommend creating a model instance and the non-static functions getRates() &amp; convert() when doing multiple conversion or getting multiple currency series for the best performance. The currency rates are stored in the provider model by date/base-currency for quick and easy access.

```
$currency = new Currency();
$values = [1, 3, 4, 5...].
foreach ($values as $value) {
    $valueNOK = $currency->convert($from = 'USD', $to = 'NOK', $value = 10, $decimals = 2);
}

$rates = $currency->getRates('NOK');
foreach ($rates as $rate) {
    $value = $valueNOK * $rate;
}
```

You can override the settings when/if you create a new instance.

```
$currency = new Currency(
    $api = 'yahoo',
    $https = false,
    $useCache = false,
    $cacheMin = 0);
...
$result = Currency:conv(
    $from = 'USD',
    $to = 'NOK',
    $value = 10,
    $decimals = 2,
    $date = '2018-12-24',
    $api = 'yahoo',
    $https = false,
    $useCache = false,
    $cacheMin = 0);
```

Use the three lettered ISO4217 code for to/from currencies: [http://en.wikipedia.org/wiki/ISO\_4217](http://en.wikipedia.org/wiki/ISO_4217)

#### Money Formatting

[](#money-formatting)

The package: gerardojbaez/money is included for an easier and more powerful Money Formatter, excellent alternative to money\_format(). You can get the values of an conversion by setting round='money' (money formatter overrides rounding).

```
Currency::conv('USD', 'USD', 10, 2);
//Result: 10
Currency::conv('USD', 'USD', 10, 'money');
//Result: $10.00
$currency->convert('USD', 'USD', 10, 'money');
//Result: $10.00
```

You can also get the money formatter itself trough the static Currency function:

```
$formater = Currency::money($amount = 0, $currency = 'USD');
```

This Money Formatter also ships with a handy helper function.

```
echo moneyFormat(10, 'USD');
//Result: $10.00
```

See Money Formatter github page for more information and usage.

### Supported functions per API

[](#supported-functions-per-api)

Default API is: The European Central Bank

Config varAPIHTTPSHistoricalSign-up requiredURLeurocentralbankThe European Central BankyesyesnoopenexchangeOpenExchangeRates.comnon-freenon-freeyescurrencylayer\*CurrencyLayernon-freeyesyesfixer\*Fixer.ioyesyesyes*\*CurrencyLayer and Fixer.io is the same company now, and it seems like the services have become one and the same.*

### Disclaimer

[](#disclaimer)

Please take note of the Terms of Use for the different data sources.

This code is released per the MIT open source license: The actual rates and conversion will vary between the data sources. In addition I am no math professor, so you should probably not use this for super serious multi-billion dollar investments. If you are gonna spend your hard earned billion dollars on the money market, you should probably use something like this:

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.7% 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 ~98 days

Recently: every ~105 days

Total

9

Last Release

2448d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1576219?v=4)[Daniel Mellum](/maintainers/danielme85)[@danielme85](https://github.com/danielme85)

---

Top Contributors

[![danielme85](https://avatars.githubusercontent.com/u/1576219?v=4)](https://github.com/danielme85 "danielme85 (61 commits)")[![mean-cj](https://avatars.githubusercontent.com/u/1191385?v=4)](https://github.com/mean-cj "mean-cj (5 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![sz4rlej](https://avatars.githubusercontent.com/u/8812575?v=4)](https://github.com/sz4rlej "sz4rlej (1 commits)")

---

Tags

currencycurrency-convertercurrency-exchange-rateslaravellaravelcurrencyconversionlaravel 5finance

### Embed Badge

![Health badge](/badges/danielme85-laravel-cconverter/health.svg)

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

###  Alternatives

[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

23.9k69.5k](/packages/grumpydictator-firefly-iii)[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[nativephp/mobile

NativePHP for Mobile

1.1k75.1k91](/packages/nativephp-mobile)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[firefly-iii/data-importer

Firefly III Data Import Tool.

8035.8k](/packages/firefly-iii-data-importer)

PHPackages © 2026

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