2017 © Pedro Peláez
 

library 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

image

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

  • Thursday, August 31, 2017
  • by msonowal
  • Repository
  • 1 Watchers
  • 2 Stars
  • 118 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 11 Versions
  • 6 % Grown

The README.md

Currency Conversions for Laravel 5.*

Latest Stable Version Total Downloads License, (*1)

Laravel 5 Library for working with multi currency conversions currently using http://fixer.io/ API., (*2)

Supports the entire Laravel 5.* releases., (*3)

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., (*4)

So you don't really have to worry about downloading/configuring API Keys., (*5)

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, (*6)

Just install the package, add the config and it is ready to use!, (*7)

Requirements

  • PHP >= 5.6.*
  • Geoip package install it from here

Installation

composer require msonowal/laraxchange

Add the service provider and facade in your config/app.php, (*8)

Service Provider, (*9)

Msonowal\Laraxchange\Providers\CurrencyServiceProvider::class,

Aliases (Facade), (*10)

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

Configuration

This library also supports optional configuration., (*11)

To get started, first publish the package config file:, (*12)

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, (*13)

Usage

Set default currency of the visitor by using the middleware add this below in Kernal.php in app/http, (*14)

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

Get ISO Currency_code of the visitor, (*15)

getUserCurrency();  // returns "USD"

Get ISO Currency_code of the visitor, (*16)

getUserCurrencySymbol();  // returns "$"

Get ISO Currency symbol of a currency, (*17)

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

Convert value from base currency to another currency on the fly, (*18)

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

Set base currency only for instance which can be changed on the fly, (*19)

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, (*20)

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

Cache the conversion rates by using command, (*21)

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, (*22)

$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, (*23)

Credits

  • Hakan Ensari for the awesome fixer.io web api
  • Daniel Stainback for the GeoIp package
  • MaxMind for the IP data

The Versions

31/08 2017

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

laravel currency laravel 5 conversion exchange currency by location currency convert on the fly cache currency

31/08 2017

v1.0.9

1.0.9.0

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

  Sources   Download

MIT

The Requires

 

laravel currency laravel 5 conversion exchange currency by location currency convert on the fly cache currency

17/07 2017

v1.0.8

1.0.8.0

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

  Sources   Download

MIT

The Requires

 

laravel currency laravel 5 conversion exchange currency by location currency convert on the fly cache currency

24/06 2017

v1.0.7

1.0.7.0

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

  Sources   Download

MIT

The Requires

 

laravel currency laravel 5 conversion exchange currency by location currency convert on the fly cache currency

30/05 2017

v1.0.6

1.0.6.0

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

  Sources   Download

MIT

The Requires

 

laravel currency laravel 5 conversion exchange currency by location currency convert on the fly cache currency

30/05 2017

v1.0.5

1.0.5.0

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

  Sources   Download

MIT

The Requires

 

laravel currency laravel 5 conversion exchange currency by location currency convert on the fly cache currency

10/04 2017

v1.0.4

1.0.4.0

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

  Sources   Download

MIT

The Requires

 

laravel currency laravel 5 conversion exchange currency by location currency convert on the fly cache currency

01/04 2017

v1.0.3

1.0.3.0

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

  Sources   Download

MIT

The Requires

 

laravel currency laravel 5 conversion exchange currency by location currency convert on the fly cache currency

23/03 2017

v1.0.2

1.0.2.0

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

  Sources   Download

MIT

The Requires

 

23/03 2017

v1.0.1

1.0.1.0

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

  Sources   Download

MIT

The Requires

 

23/03 2017

v1.0.0

1.0.0.0

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

  Sources   Download

MIT

The Requires