This extension will help to find out current currency conversion rate using various providers.
Documentation is at https://github.com/imanilchaudhari/yii2-currency-converter/blob/master/docs/README.md.
Version 1 docs are located at here.
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist imanilchaudhari/yii2-currency-converter "3.1"
or add
"imanilchaudhari/yii2-currency-converter": "3.1"
to the require section of your composer.json
file.
Once the extension is installed, use it in your code by adding the below code on the config's components :
'components' => [
'currencyConverter' => [
'class' => 'imanilchaudhari\CurrencyConverter\CurrencyConverter',
'provider' => [
'class' => 'imanilchaudhari\CurrencyConverter\Provider\ExchangeRatesApi',
],
],
...
],
and use as
$rate = Yii::$app->currencyConverter->convert('USD', 'NPR');
OR
use imanilchaudhari\CurrencyConverter\CurrencyConverter;
use imanilchaudhari\CurrencyConverter\Provider\ExchangeRatesApi;
$converter = new CurrencyConverter([
'provider' => [
'class' => ExchangeRatesApi::class,
],
]);
$rate = $converter->convert('USD', 'NPR');
print_r($rate); // it will print the current Nepalese currency (NPR) rate according to USD
The package is tested with PHPUnit. To run tests:
./vendor/bin/phpunit
The Yii2 Currency Converter is free software. It is released under the terms of the MIT License. Please see LICENSE
for more information.
Comments