equentor / laravel-open-exchange-rates
此包已被废弃且不再维护。没有建议替代包。
用于与 Open Exchange Rates API 交互的包。
dev-master
2017-06-06 00:48 UTC
This package is not auto-updated.
Last update: 2018-08-30 12:00:36 UTC
README
此包为与 Open Exchange Rates 服务交互提供了一个简单便捷的接口。目前支持免费端点。
通过 Composer 安装
将以下内容添加到你的 composer.json
文件中的 require 对象
"equentor/laravel-open-exchange-rates": "dev-master"
之后,运行 composer install
安装包。将服务提供者添加到 app/config/app.php
文件中的 providers 数组
'providers' => [ // ... Equentor\LaravelOpenExchangeRates\LOERServiceProvider::class, ]
最后,发布配置文件。
php artisan vendor:publish
使用示例
在 config/loer.php
return [ 'app_id' => '*****************************', // your own api key 'default_base_currency' => 'USD' ];
在控制器(或服务)方法中
use Equentor\LaravelOpenExchangeRates\Client; class SomeController extends Controller { private $client; public function __construct(Client $client) { $this->client = $client; } public function someAction() { $coefficient = $this->client->latest('USD,RUB,AWG'); $historical_coefficent $this->client->historical('2011-03-05', 'USD,RUB,AWG'); // e.t.c... // Change in base currencies (not allowed for free account) and requests for the coefficients of all currencies relative to. $coefficient = $this->client->currency('RUB')->latest(); } }