PHPackages                             zhouyl/apiclient - 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. zhouyl/apiclient

ActiveLibrary

zhouyl/apiclient
================

Common API Client

012PHP

Since Jul 26Pushed 11y ago1 watchersCompare

[ Source](https://github.com/zhouyl/ApiClient)[ Packagist](https://packagist.org/packages/zhouyl/apiclient)[ RSS](/packages/zhouyl-apiclient/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

通用 API 客户端
==========

[](#通用-api-客户端)

Composer 加载说明
-------------

[](#composer-加载说明)

```
{
    "require": {
        "zhouyl/apiclient": "dev-master"
    }
}
```

使用说明
----

[](#使用说明)

### 示例代码

[](#示例代码)

```
$api = new \ZhouYL\Api\Client([
    'gateway' => 'http://127.0.0.1',
    'headers' => array(
        'Host: api.fanqie88.com',
    ),
    'port' => 9433,
    'timeout' => 10,
]);
```

### config: 配置参数

[](#config-配置参数)

参数说明：

```
gateway:    URL请求网关
port:       端口，默认自动识别
headers:    CURL请求附加头信息
timeout:    超时时间，默认不限制

```

### request: 执行请求

[](#request-执行请求)

```
$json = $api->request('Api/xxx', array('key' => 'xxx', 'uid' => 12345), 'POST');
```

### get: GET 请求

[](#get-get-请求)

```
$json = $api->request('Api/xxx');
// or
$json = $api->get('Api/xxx');
```

### post: POST 请求

[](#post-post-请求)

```
$data = array(
    'key' => 'xxx',
    'uid' => 12345,
);

$json = $api->request('Api/xxx', $data, 'POST');
// or
$json = $api->post('Api/xxx', $data);
```

### response: 获取响应数据

[](#response-获取响应数据)

Client 将尝试将响应数据转换进行 json\_decode 转换，如果失败则返回 false

```
$api->request('Api/xxx');
$json = $api->response();

```

### rawResponse: 获取原始响应数据

[](#rawresponse-获取原始响应数据)

```
$raw = $api->rawResponse();
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/670a28674a5d1c4feb1817a0214b725395c08fbd0c41d5c4dc269a2f27f41620?d=identicon)[zhouyl](/maintainers/zhouyl)

---

Top Contributors

[![zhouyl](https://avatars.githubusercontent.com/u/1251541?v=4)](https://github.com/zhouyl "zhouyl (2 commits)")

### Embed Badge

![Health badge](/badges/zhouyl-apiclient/health.svg)

```
[![Health](https://phpackages.com/badges/zhouyl-apiclient/health.svg)](https://phpackages.com/packages/zhouyl-apiclient)
```

PHPackages © 2026

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