xigen.io / currency-converter-bundle
此包的最新版本(v2.0.1)没有可用的许可信息。
Symfony 的货币转换工具包
v2.0.1
2019-01-26 14:46 UTC
Requires
- php: ^7.2
- guzzlehttp/guzzle: ^6.3
- symfony/framework-bundle: ^3.4|^4
README
Symfony 的货币转换工具包
提供了一种简单的方法,在 Symfony 项目中使用 fixer.io API 将英镑金额转换为常用货币。汇率存储在 symfony 缓存中,最多 4 小时后自动更新。
安装
composer require xigen.io/currency-converter-bundle
最后在 app/AppKernel.php
中注册该包(如果使用 Symfony 3)
$bundles = [ [...] new Xigen\Bundle\CurrencyConverterBundle\CurrencyConverterBundle(), ];
使用
// Fetch the convert service $convert = $this->getContainer()->get('currency_converter.convert'); // Convert 10 euros into pounds $pounds = $convert->from('EUR', 10); // Convert 10 pounds into euros $euros = $convert->to('EUR', 10); dump([ 'pounds' => $pounds, 'euros' => $euros, ]);