qbil-software/openexchangeratesbundle
Composer 安装命令:
composer require qbil-software/openexchangeratesbundle
包简介
Symfony 2.8 + compatible bundle for fetching foreign exchange rates from openexchangerates.com. Symfony wrapper for `qbil-software/openexchangerates` package
README 文档
README
Symfony 4+ compatible bundle for fetching foreign exchange rates from openexchangerates.com. Symfony wrapper for qbil-software/openexchangerates package
Installation
-
Add
qbil-software/openexchangeratesbundletocomposer.jsonfile -
Run
composer update -
Register bundle by adding following line to
AppKernel.phpnew Qbil\OpenExchangeRateBundle\QbilOpenExchangeRatesBundle() -
Add
qbil_open_exchange_rates.app_id: APP_IDandqbil_open_exchange_rates.base_currency: BASE_CURRENCY_SYMBOLtoparameters.ymlwhere APP_ID is you app_id (See https://docs.openexchangerates.org/docs/authentication for more info about app_id) and BASE_CURRENCY_SYMBOL is you base currency (See https://docs.openexchangerates.org/docs/set-base-currency for more info about base currency). Default base currency is USD. If you dont wish to change base currency, set it to~ -
You are ready to use the bundle now.
Usage
Open exchange rates bundle comes with a service with id Qbil\OpenExchangeRates\Exchange, which can be injected into another services via dependency injection provided by symfony.
Methods
The service provides five public methods latest, historical, between, convert and currencies.
All methods except currencies (which accepts no argument) can accept an associative array as argument with following keys
symbolsorcurrencies- Get foreign exchange rates of only give currencies (in comma separated format).
For example
$this-get('qbil_open_exchange_rates.exchange')->latest(['symbols' => 'USD,EUR,GBP'])will return an array of latest foreign exchange rates of currencies USD, EUR and GBPbase- Even if you specified base currency inparameters.ymlfile, you can override it in each request addingbasekey to arguments array
For example
$this-get('qbil_open_exchange_rates.exchange')->latest(['base' => 'GBP'])will return an array of latest foreign exchange rates with respect to base currency GBP
Methods explained
-
latest- This method fetches latest foreign exchange rates. e.g.$this-get('qbil_open_exchange_rates.exchange')->latest()will return an array of latest exchange rates. -
historical- This method fetches foreign exchange rates of a particular date. It has a required argument keydate(yyyy-mm-dd format), i.e. the date of which foreign exchange rates you want to fetch .e.g.$this-get('qbil_open_exchange_rates.exchange')->historical(['date' => '2017-10-01'])will return an array of exchange rates of date 2017-10-01. -
between- This method fetches foreign exchange rates between particular dates specified by arguments keystartandend(both in yyyy-mm-dd format) .e.g.$this-get('qbil_open_exchange_rates.exchange')->between(['start' => '2017-10-01', 'end' => '2017-11-05'])will return an array of exchange rates of between 2017-10-01 and 2017-11-05. -
convert- This method is used to convert any money value from one currency to another at the latest foreign exchange rates. It has three required argument keysamount,fromandto.fromandtoare currency codes (3 letters) andamountis the amount you want to convert. e.g.$this-get('qbil_open_exchange_rates.exchange')->between(['amount' => '15678800', 'from' => 'USD', 'to' => 'EUR'])will return equivalent amount in EUR (as string) -
currencies- This method returns array of all supported currencies with symbol as their key and currency as their value.
Note: Some of the above methods are only available in enterprise or ultimate edition. Please visit https://openexchangerates.com for more info
qbil-software/openexchangeratesbundle 适用场景与选型建议
qbil-software/openexchangeratesbundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 192k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2018 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 qbil-software/openexchangeratesbundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 qbil-software/openexchangeratesbundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 192k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-12-07