otifsolutions/currency-layer
Composer 安装命令:
composer require otifsolutions/currency-layer
包简介
This Laravel package provides easy integration with Currency Layer Api along with complete list for countries with flag information. It also comes with command to auto sync rates for each currency
README 文档
README
Laravel Currency Layer
This Laravel package provides easy integration with Currency Layer Api along with complete list for countries with flag information. It also comes with command to auto sync rates for each currency
Requirements
PHP >= 7.4
Laravel >= 8.0
How to use the Library
Install via Composer (Recommended)
Using Composer
composer require otifsolutions/currency-layer
Note :
This package works with database engine
myIsam. If you are usingmysql databasethen you have to change database engine tomyIsamfrom config/database.php ->'connection' => 'mysql'and make this change'engine' => 'myIsam'
Now, run the migrations
php artisan migrate
Then, run this command to populate all tables with countries, states, currencies etc data
php artisan fill:tables
Now follow the instructions below
Grab the access key by registering on CurrencyLayer, give the key to the app using artisan tinker or by writing this line anywhere in the code, where yourAccessKey (string) is the key you've got from the API
OTIFSolutions\Laravel\Settings\Models\Setting::set('crlKey', 'yourAccessKey');
Set the numberOfDays key (positive integer), where this is the data of how many days you want to keep:
OTIFSolutions\Laravel\Settings\Models\Setting::set('daysRates', numberOfDays);
Note:
To check what key you have set, try with
getmethod like
OTIFSolutions\Laravel\Settings\Models\Setting::get('daysRates');
and
OTIFSolutions\Laravel\Settings\Models\Setting::get('crlKey');
If you have set the crlKey somewhere in the code, remove that line
after first time execution. To reset or re-assign the key, you can use the same line.
But, it is recommended to use tinker to set the access key.
After setting all the things, you can now synchronize currency exchange rates data
Hit this command to fetch the exchange rates
php artisan rates:get
Hit this command to remove the exchange rates
php artisan rates:delete
Now publish countries flags from package to your project
php artisan publish:flags
Note :
Commands
rates:deleteandrates:getcan only be executed when you set the keyscrlKeyanddaysRates
Relationships defined between Models
Model Country has OneToOne relation and Currency, ManyToMany relation with Timezone and OneToMany relation with State.
State Model has OneToMany relation with City
Currency Model has OneToMany relation with CurrencyRate
otifsolutions/currency-layer 适用场景与选型建议
otifsolutions/currency-layer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 73 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 04 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 otifsolutions/currency-layer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 otifsolutions/currency-layer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 73
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-04-14