Skip to content

Latest commit

 

History

History
52 lines (40 loc) · 1.85 KB

README.md

File metadata and controls

52 lines (40 loc) · 1.85 KB

Yii2 Currency Converter

This package provides the most famous currency rates providers' implementations. The package was originally built on Yahoo API, but there was a discontinuation of it. It is therefore highly recommended that you make use of only active providers, such as the ones listed below.

Usage

Once the extension is installed, simply use it in your code by :

'components' => [
    'currencyConverter' => [
        'class' => 'imanilchaudhari\CurrencyConverter\CurrencyConverter',
        'provider' => [
            'class' => 'imanilchaudhari\CurrencyConverter\Provider\ExchangeRatesApi',
        ],
    ],
    ...
],

$converter = Yii::$app->currencyConverter;
$rate =  $converter->convert('USD', 'NPR');

OR

use imanilchaudhari\CurrencyConverter\CurrencyConverter;
use imanilchaudhari\CurrencyConverter\Provider\OpenExchangeRatesApi;

$converter = new CurrencyConverter([
    'provider' => [
        'class' => OpenExchangeRatesApi::class,
        'appId' => Yii::$app->params['openExchangeRate']['appId'],
    ],
]);
$rate =  $converter->convert('USD', 'NPR');

print_r($rate);  // it will print current Nepalese currency (NPR) rate according to USD

Active Providers