openwse / swap
4.3.1
2022-03-02 20:32 UTC
Requires
- php: ^7.1.3 || ^8.0
- openwse/exchanger: ^2.7
Requires (Dev)
- nyholm/psr7: ^1.0
- php-http/message: ^1.7
- php-http/mock-client: ^1.0
- phpunit/phpunit: ^7 || ^8 || ^9
This package is not auto-updated.
Last update: 2024-09-27 06:41:12 UTC
README
Swap 允许您从各种服务(如 Fixer、currencylayer、exchangeratesapi 或 Abstract)检索货币汇率,并可选择缓存结果。它集成到其他库中,如 moneyphp/money,并提供一个 Symfony Bundle 和一个 Laravel 包。
赞助商
快速开始
$ composer require php-http/curl-client nyholm/psr7 php-http/message florianv/swap
use Swap\Builder; // Build Swap $swap = (new Builder()) // Use the Fixer.io service as first level provider ->add('fixer', ['access_key' => 'your-access-key']) // Use the currencylayer.com service as first fallback ->add('currency_layer', ['access_key' => 'secret', 'enterprise' => false]) // Use the exchangeratesapi.io service as second fallback ->add('exchange_rates_api', ['access_key' => 'secret']) // Use the abstractapi.com service as third fallback ->add('abstract_api', ['api_key' => 'secret']) ->build(); // Get the latest EUR/USD rate $rate = $swap->latest('EUR/USD'); // 1.129 $rate->getValue(); // 2016-08-26 $rate->getDate()->format('Y-m-d'); // Get the EUR/USD rate 15 days ago $rate = $swap->historical('EUR/USD', (new \DateTime())->modify('-15 days'));
我们建议使用 支持我们项目的服务,提供每天最多 1,000 次请求的免费计划。
文档
当前分支的文档可以在 这里 找到。
服务
以下是当前实现的服务列表
此外,只要它们实现了 ExchangeRateService
接口,您就可以添加自己的服务。
集成
- 一个 Symfony Bundle FlorianvSwapBundle
- 一个 Laravel 包 florianv/laravel-swap
鸣谢
许可证
MIT 许可证 (MIT)。更多信息请参阅 LICENSE。