centrex / laravel-open-exchange-rates
这是我创建的包:laravel-open-exchange-rates
v1.1.0
2024-09-19 13:00 UTC
Requires
- php: ^8.1|^8.2
- illuminate/database: ^10.0|^11.0
- illuminate/support: ^10.0|^11.0
Requires (Dev)
- larastan/larastan: ^2.0
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.8
- orchestra/testbench: ^8.8
- pestphp/pest: ^2.30
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- rector/rector: ^1.1
- spatie/laravel-ray: ^1.26
README
此包提供了一个简单方便的接口,用于与 Open Exchange Rates 服务交互。目前支持免费端点。
内容
安装
您可以通过 composer 安装此包
composer require centrex/laravel-open-exchange-rates
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="laravel-open-exchange-rates-config"
这是已发布配置文件的内容
return [ 'app_id' => 'your_own_appid', 'default_base_currency' => 'USD' ];
使用方法
在 config/loer.php 中
return [ 'app_id' => '*****************************', // your own api key 'default_base_currency' => 'USD' ];
在控制器(或服务)方法中
use Centrex\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(); } }
测试
使用 Pint 保持现代代码库
composer lint
使用 Rector 运行重构
composer refacto
使用 PHPStan 运行静态分析
composer test:types
使用 PEST 运行单元测试
composer test:unit
运行整个测试套件
composer test
变更日志
有关最近更改的更多信息,请参阅 变更日志
贡献
有关详细信息,请参阅 贡献指南
鸣谢
许可
MIT 许可证(MIT)。有关更多信息,请参阅 许可文件