chandachewe/currency 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

chandachewe/currency

最新稳定版本:v1.0.1

Composer 安装命令:

composer require chandachewe/currency

包简介

A PHP Package to convert amount from one currency to the other

README 文档

README

A PHP Package to convert Amount from one currency to the other.

Requirements

  • PHP >= 7.3

Installation

Install currency using composer require:

composer require chandachewe/currency 

Enter the currency directory and run the following code

composer install

Add the namespaces and vendor/autoload in the file you will be doing your conversions from. Am assuming the file and the vendor are both in the root directory. In your file include the following on top:

 require 'vendor/autoload.php';  
 use Chandachewe\Currency\DriverAccessKeys\ExchangeRateDriverAccessKey; 
 use Chandachewe\Currency\Drivers\ExchangeConverter;
 use Chandachewe\Currency\Drivers\ExchangeRate;
 use Chandachewe\Currency\CurrencyConverted;
 use Chandachewe\Currency\CurrencyFormats;
 

Usage

Convert Amount from One Currency to the other

You can convert the amount from one currency to the other using the following code:

ExchangeRateDriverAccessKey::$exchangerate_access_key = 'YOUR ACCESS KEY HERE';
ExchangeConverter::convert('amount', 'from this currency', 'to this currency');

Important: See the supported currency formats below. Use of unsupported formats will throw an exception

Suppose I want to convert 10 USD to GBP then my code will be:

ExchangeRateDriverAccessKey::$exchangerate_access_key = 'YOUR ACCESS KEY HERE';
echo ExchangeConverter::convert(10, 'USD', 'GBP');

Then you can retrieve the result as follows:

echo CurrencyConverted::$currency_conversion 

Obtain the Exchange rate between two currencies

You can also obtain the exchange rates between two currencies as follows:

ExchangeRateDriverAccessKey::$exchangerate_access_key = 'YOUR ACCESS KEY HERE';
ExchangeRate::exchange('from this currency', 'to this currency');

Suppose I want to obtain the exchange rate between 1 USD and the GBP then my code will be as follows:

ExchangeRateDriverAccessKey::$exchangerate_access_key = 'YOUR ACCESS KEY HERE';
echo ExchangeRate::exchange('USD', 'GBP');

Then you can retrieve the result as follows:

echo CurrencyConverted::$currency_rate;

Drivers

Available Drivers

Versioning

Releases will be numbered with the following format:

<major>.<minor>.<patch>

Supported Currency Formats

  • AED
  • AFN
  • ALL
  • AMD
  • ANG
  • AOA
  • ARS
  • AUD
  • AWG
  • AZN
  • BAM
  • BBD
  • BDT
  • BGN
  • BHD
  • BIF
  • BMD
  • BND
  • BOB
  • BRL
  • BSD
  • BTC
  • BTN
  • BWP
  • BYN
  • BZD
  • CAD
  • CDF
  • CHF
  • CLF
  • CLP
  • CNH
  • CNY
  • COP
  • CRC
  • CUC
  • CUP
  • CVE
  • CZK
  • DJF
  • DKK
  • DOP
  • DZD
  • EGP
  • ERN
  • ETB
  • EUR
  • FJD
  • FKP
  • GBP
  • GEL
  • GGP
  • GHS
  • GIP
  • GMD
  • GNF
  • GTQ
  • GYD
  • HKD
  • HNL
  • HRK
  • HTG
  • HUF
  • IDR
  • ILS
  • IMP
  • INR
  • IQD
  • IRR
  • ISK
  • JEP
  • JMD
  • JOD
  • JPY
  • KES
  • KGS
  • KHR
  • KMF
  • KPW
  • KRW
  • KWD
  • KYD
  • KZT
  • LAK
  • LBP
  • LKR
  • LRD
  • LSL
  • LYD
  • MAD
  • MDL
  • MGA
  • MKD
  • MMK
  • MNT
  • MOP
  • MRU
  • MUR
  • MVR
  • MWK
  • MXN
  • MYR
  • MZN
  • NAD
  • NGN
  • NIO
  • NOK
  • NPR
  • NZD
  • OMR
  • PAB
  • PEN
  • PGK
  • PHP
  • PKR
  • PLN
  • PYG
  • QAR
  • RON
  • RSD
  • RUB
  • RWF
  • SAR
  • SBD
  • SCR
  • SDG
  • SEK
  • SGD
  • SHP
  • SLL
  • SOS
  • SRD
  • SSP
  • STD
  • STN
  • SVC
  • SYP
  • SZL
  • THB
  • TJS
  • TMT
  • TND
  • TOP
  • TRY
  • TTD
  • TWD
  • TZS
  • UAH
  • UGX
  • USD
  • UYU
  • UZS
  • VES
  • VND
  • VUV
  • WST
  • XAF
  • XAG
  • XAU
  • XCD
  • XDR
  • XOF
  • XPD
  • XPF
  • XPT
  • YER
  • ZAR
  • ZMW
  • ZWL

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-08