PHPackages                             wavpa/exchange-rate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wavpa/exchange-rate

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wavpa/exchange-rate
===================

An exchange rate SDK

0.0.1(5y ago)05MITPHP

Since Aug 25Pushed 5y ago1 watchersCompare

[ Source](https://github.com/wavpa/exchange-rate)[ Packagist](https://packagist.org/packages/wavpa/exchange-rate)[ RSS](/packages/wavpa-exchange-rate/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

ExchangeRate
============

[](#exchangerate)

基于[极速数据汇率查询](https://www.jisuapi.com/api/exchange/)的汇率组件。

安装
--

[](#安装)

```
composer require wavpa/exchange-rate -vvv
```

配置
--

[](#配置)

在使用本扩展之前，你需要去极速数据注册账号，然后创建应用，获取应用的 API Key。

使用
--

[](#使用)

```
use Wavpa\ExchangeRate\ExchangeRate;

$key = 'xxxxxxxxxxxxxxxx';

$exchangeRate = new ExchangeRate($key);
```

汇率转换
----

[](#汇率转换)

```
$response = $exchangeRate->convert('CNY', 'USD');
```

示例:

```
{
    "status":0,
    "msg":"ok",
    "result":{
        "from":"CNY",
        "to":"USD",
        "fromname":"人民币",
        "toname":"美元",
        "updatetime":"2020-08-24 16:04:42",
        "rate":"0.1447",
        "camount":0.1447
    }
}
```

参数说明
----

[](#参数说明)

```
string convert(string $from, string $to)
```

- $from 要换算的单位，比如：“CNY“；
- $to 换算后的单位，比如：“USD“；

在 Laravel 中使用
-------------

[](#在-laravel-中使用)

在 Laravel 中使用也是同样的安装方式，配置写在`config/services.php`中：

```
'exchange-rate' => [
    'key' => env('EXCHANGE_RATE_API_KEY'),
],
```

然后在`.env`中配置`EXCHANGE_RATE_API_KEY`：

```
EXCHANGE_RATE_API_KEY=xxxxxxxxxxxxxxxx

```

可以用两种方式来获取`Wavpa\ExchangeRate\ExchangeRate`实例：

1. 方法参数注入

```
public function convert(Request $request, ExchangeRate $exchangeRate, $from, $to)
{
    return $exchangeRate->convert($from, $to);
}
```

2. 服务名访问

```
public function convert(Request $request, $from, $to)
{
    return app('exchange-rate')->convert($from, $to);
}
```

参考
--

[](#参考)

[极速数据汇率查询](https://www.jisuapi.com/api/exchange/)

License
-------

[](#license)

MIT

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2084d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/70138271?v=4)[wavpa](/maintainers/wavpa)[@wavpa](https://github.com/wavpa)

---

Top Contributors

[![luyoyo63](https://avatars.githubusercontent.com/u/62836348?v=4)](https://github.com/luyoyo63 "luyoyo63 (1 commits)")

### Embed Badge

![Health badge](/badges/wavpa-exchange-rate/health.svg)

```
[![Health](https://phpackages.com/badges/wavpa-exchange-rate/health.svg)](https://phpackages.com/packages/wavpa-exchange-rate)
```

###  Alternatives

[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[dhlparcel/magento2-plugin

DHL Parcel plugin for Magento 2

11180.5k2](/packages/dhlparcel-magento2-plugin)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
