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

yii_logo.svg

Yii2 Currency Converter

  1. Requirements
  2. Installation
  3. Usage
  4. Exchange Rate Providers
  5. Testing
  6. License

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 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 : `php 'components' => [

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

],

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


***OR***

```php
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

0 0
1 follower
11 172 downloads
Yii Version: 2.0
License: MIT
Category: Others
Tags:
Developed by: Anil Chaudhari
Created on: Apr 15, 2018
Last updated: (not set)
Packagist Profile
Github Repository