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.1"

or add

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

to the require section of your composer.json file.

Usage

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

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.1 Jul 9, 2024

  • enh: restruct & readme file updated

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.109 July 2024
  • 3.006 April 2024
  • 2.026 February 2024
  • 1.108 April 2018
  • 1.010 September 2015

Comments



3.1 is the latest of 5 releases



MIT license
Stats
18 github stars & 10 github forks
0 downloads in the last day
87 downloads in the last 30 days
11374 total downloads