imanilchaudhari/yii2-currency-converter This extension will help to find out current currency conversion rate.

extension

yii_logo.svg

Yii2 Currency Converter


Latest Stable Version Total Downloads Build Status Code Coverage

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.

Requirements

  • PHP version 7.4 or later
  • Curl Extension (Optional)

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist imanilchaudhari/yii2-currency-converter "3.0"

or add

"imanilchaudhari/yii2-currency-converter": "3.0"

to the require section of your composer.json file.

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

Exchange Rate Providers

Testing

Unit testing

The package is tested with PHPUnit. To run tests:

./vendor/bin/phpunit

License

The Yii2 Currency Converter is free software. It is released under the terms of the MIT License. Please see LICENSE for more information.

Powered by

Changelog

Yii2 Currency Converter Change Log

3.0 Apr 6, 2024

  • enh: removed obsolete providers & added new providers

2.0 Feb 27, 2024

  • Enh: Removed package's cache provider and use Yii's built in cache provider

1.1 Apr 8, 2018

  • OpenExchangeRatesApi rates provider added
  • FixerApi rates provider added
  • JsonRatesApi rates provider added
  • CurrencylayerApi rates provider added

1.0 Aug 5, 2015

  • Initial release.

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

  • 3.006 April 2024
  • 2.026 February 2024
  • 1.108 April 2018
  • 1.010 September 2015

Comments



3.0 is the latest of 4 releases



MIT license
Stats
18 github stars & 10 github forks
1 downloads in the last day
42 downloads in the last 30 days
11172 total downloads