PHPackages                             msonowal/laraxchange - 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. msonowal/laraxchange

ActiveLibrary[API Development](/categories/api)

msonowal/laraxchange
====================

This provides multi currency conversions in Laravel app by using http://fixer.io/ API and cache the conversion rates by using cache driver specified and updates the cache for the app periodically by the command bus in laravel way

v1.2.3(7y ago)72.2k2[1 issues](https://github.com/msonowal/laraxchange/issues)[1 PRs](https://github.com/msonowal/laraxchange/pulls)MITPHPPHP &gt;=7.0

Since Mar 23Pushed 2y ago1 watchersCompare

[ Source](https://github.com/msonowal/laraxchange)[ Packagist](https://packagist.org/packages/msonowal/laraxchange)[ RSS](/packages/msonowal-laraxchange/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (8)Dependencies (4)Versions (16)Used By (0)

Currency Conversions for Laravel 5.\*
=====================================

[](#currency-conversions-for-laravel-5)

[![Latest Stable Version](https://camo.githubusercontent.com/a000c41283092381948a914b283337540c63e79daeffc7db89657ad44cf5ca81/68747470733a2f2f706f7365722e707567782e6f72672f6d736f6e6f77616c2f6c617261786368616e67652f762f737461626c65)](https://packagist.org/packages/msonowal/laraxchange)[![Total Downloads](https://camo.githubusercontent.com/be2c68091ff6ae09c2eaea3a6af78ba7a211302caded61996fa179fcb397f2bc/68747470733a2f2f706f7365722e707567782e6f72672f6d736f6e6f77616c2f6c617261786368616e67652f646f776e6c6f616473)](https://packagist.org/packages/msonowal/laraxchange)[![License](https://camo.githubusercontent.com/3765e625ee408885ce0734d95a5aba14bcf727edaeadba6b02b82d0d8132433f/68747470733a2f2f706f7365722e707567782e6f72672f6d736f6e6f77616c2f6c617261786368616e67652f6c6963656e7365)](https://packagist.org/packages/msonowal/laraxchange)

Laravel 5 Library for working with multi currency conversions currently using  API.

Supports the entire Laravel 5.\* releases.

In contrary to all other packages wherein it requires that you have to configure your provider, this library calls a free service and works with zero setup configs. This package utilizes built in laravel cache driver for caching the conversion rates and it also provides commands for artisan lovers and which can be scheduled so that it will periodically updates your cache storage.

So you don't really have to worry about downloading/configuring API Keys.

It also provides a middleware which automatically determines the currency and set it for the Visitor if there are no currency set in the session which depends on GeoIp [package](https://packagist.org/packages/torann/geoip)

Just install the package, add the config and it is ready to use!

Requirements
============

[](#requirements)

- PHP &gt;= 5.6.\*
- Geoip package install it from [here](https://packagist.org/packages/torann/geoip)

Installation
============

[](#installation)

```
composer require msonowal/laraxchange

```

Add the service provider and facade in your config/app.php

Service Provider

```
Msonowal\Laraxchange\Providers\CurrencyServiceProvider::class,

```

Aliases (Facade)

```
'Currency'      =>  Msonowal\Laraxchange\Facades\Currency::class,

```

Configuration
=============

[](#configuration)

This library also supports optional configuration.

To get started, first publish the package config file:

```
php artisan vendor:publish --provider="Msonowal\Laraxchange\Providers\CurrencyServiceProvider"
```

- `base_currency`: defines the base currency for the app.
- `default_currency`: defines the default\_currency when no currency code is present for conversions.
- `valid_currencies`: defines the currencies that are allowed to set for the applications.
- `cache_key`: defines the cache\_key for storing and retrieval to use with caching.
- `cache_expiry`: defines the cache\_expiry in minutes for how long the currencies will be store in cache.

It provides various built in helper methods to get the user currency or setting the currency

Usage
=====

[](#usage)

Set default currency of the visitor by using the middleware add this below in `Kernal.php` in `app/http`

```
'determine_currency'    =>  \Msonowal\Laraxchange\Middleware\SetDefaultUserCurrency::class,

```

Get ISO Currency\_code of the visitor

```
getUserCurrency();  // returns "USD"

```

Get ISO Currency\_code of the visitor

```
getUserCurrencySymbol();  // returns "$"

```

Get ISO Currency symbol of a currency

```
getCurrencySymbol("USD");  // returns "$"

```

Convert value from base currency to another currency on the fly

```
convertCurrency($value, "GBP");  // returns the value in GBP currency

```

Set base currency only for instance which can be changed on the fly

```
Currency::setBaseCurrency("GBP"); // sets the base currency as specified for that instance when default base currency is different

```

Get All Conversions list of the currencies based on the base currency specified

```
Currency::getRates();  // returns list of values fore each currency

```

Cache the conversion rates by using command

```
php artisan currency:cache;  // will cache currency conversion rates for each available currency specified in config `valid_currencies`

```

To cache the rates automatically add the command in your `Kernal.php` in app/Console `directory` below

```
$schedule->command('currency:cache')->daily()->at('12:00');  // will cache currency conversion rates for each available currency specified in config `valid_currencies`

```

There are so many other methods which can be explored by yourself

Credits
=======

[](#credits)

- Hakan Ensari for the awesome [fixer.io](http://fixer.io) web api
- Daniel Stainback for the GeoIp [package](https://packagist.org/packages/torann/geoip)
- MaxMind for the IP data

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 69.2% 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 ~59 days

Recently: every ~153 days

Total

14

Last Release

2615d ago

### Community

Maintainers

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

---

Top Contributors

[![msonowal](https://avatars.githubusercontent.com/u/6334484?v=4)](https://github.com/msonowal "msonowal (9 commits)")[![dhritimannath](https://avatars.githubusercontent.com/u/21237970?v=4)](https://github.com/dhritimannath "dhritimannath (3 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")

---

Tags

apicurrencyfixer-iogeocurrencylaravellaravel-5-packagelaravelcurrencyconversionlaravel 5exchangecurrency by locationcurrency convert on the flycache currency

### Embed Badge

![Health badge](/badges/msonowal-laraxchange/health.svg)

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

###  Alternatives

[illuminate/http

The Illuminate Http package.

11937.2M6.6k](/packages/illuminate-http)[torchlight/torchlight-laravel

A Laravel Client for Torchlight, the syntax highlighting API.

120482.3k12](/packages/torchlight-torchlight-laravel)[flarum/core

Delightfully simple forum software.

201.4M2.2k](/packages/flarum-core)[simplestats-io/laravel-client

Analytics for Laravel. Track visitors, registrations, and payments. Discover which channels actually drive revenue, not just traffic. Server-side, GDPR compliant, ad-blocker proof.

5019.3k](/packages/simplestats-io-laravel-client)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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