oasin/bitcoin-converter
Composer 安装命令:
composer require oasin/bitcoin-converter
包简介
Convert Bitcoin to Fiat currency
README 文档
README
This library helps fintech developers to convert bitcoin to fiat currency or to another cryptocurrency and vice versa.
Available exchange rates providers are:
Features
It is simple, lightweight, extensible, framework agnostic and fast.
- You can convert Bitcoin to any currency (ISO 4217 fiat or another cryptocurrency)
- You can convert any currency (ISO 4217 fiat or another cryptocurrency) to Bitcoin
- It supports different exchange rates providers: Coinbase, Coindesk, Bitpay
- It has baked-in caching (PSR16 compliant, swappable with your own or your framework's)
Install
Lets begin by installing the library by Composer:
$ composer require mitmelon/bitcoin-converter:dev-main
Usage
You can then convert Bitcoin to any currency (ISO 4217 fiat or crypto) by:
use Oasin\BitcoinConverter\Converter; $convert = new Converter; // uses Coinbase as default provider echo $convert->toCurrency('USD', 0.5); echo $convert->toCurrency('LTC', 0.5);
You can also convert any currency (ISO 4217 fiat or crypto) to Bitcoin:
use Oasin\BitcoinConverter\Converter; $convert = new Converter; // uses Coinbase as default provider echo $convert->toBtc(100, 'USD'); echo $convert->toBtc(20, 'LTC');
and it also has its helper function for convenience:
// uses Coinbase as default provider echo to_btc(100, 'USD'); echo to_btc(20, 'LTC');
You can use different exchange rates from providers:
use Oasin\BitcoinConverter\Converter; use Oasin\BitcoinConverter\Provider\CoinbaseProvider; use Oasin\BitcoinConverter\Provider\CoindeskProvider; use Oasin\BitcoinConverter\Provider\BitpayProvider; $convert = new Converter(new CoinbaseProvider); $convert = new Converter(new CoindeskProvider); $convert = new Converter(new BitpayProvider);
You can specify cache expire time (ttl) on provider by:
new CoinbaseProvider($httpClient, $psr16CacheImplementation, 5); // cache expires in 5mins, defaults to 60mins
Contributing
Open for suggestions and requests. Please request through [issue][link-issue] or [pull requests][link-pull-request].
License
The MIT License (MIT). Please see License File for more information.
oasin/bitcoin-converter 适用场景与选型建议
oasin/bitcoin-converter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 03 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 oasin/bitcoin-converter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 oasin/bitcoin-converter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-18