PHPackages                             mantoufan/yzhangateway - 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. mantoufan/yzhangateway

ActiveLibrary

mantoufan/yzhangateway
======================

Developing PHP SDK for any API. 为任何 API 快速开发 PHP SDK.

1.0.6(1y ago)331.4k1MITPHPPHP &gt;=5.4

Since Sep 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mantoufan/yzhanGateway)[ Packagist](https://packagist.org/packages/mantoufan/yzhangateway)[ RSS](/packages/mantoufan-yzhangateway/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (8)Used By (1)

yzhanGateway
============

[](#yzhangateway)

Developing PHP SDK for any API.
为任何 API 快速开发 PHP SDK.

Install 安装
----------

[](#install-安装)

```
composer require mantoufan/yzhangateway
```

Usage 使用
--------

[](#usage-使用)

### {root}/src

[](#rootsrc)

#### Client

[](#client)

1. Create a `{client name}.php` in `src\Client` Directory
2. 在 `src\Client` 目录新建一个 `{客户端名称}.php`
3. Implement `request` method
4. 实现请求 `request` 方法

#### Auth

[](#auth)

如需要，新建 `.php` 提供鉴权类
例如包含获取 `authorization` 请求头的方法
If necessary, create a new `.php` to provide an authentication class,
such as a method to obtain the `authorization` request header

#### Exception

[](#exception)

如需要，新建 `.php` 声明新错误类型
If necessary, create a new `.php` here to declare a new error type

#### Tool

[](#tool)

##### ClientTool

[](#clienttool)

提供 `Request` 静态方法，发出请求和响应
Provides the `Request` static method for making requests and responses

### {root}/tests

[](#roottests)

#### {root}/.env.test

[](#rootenvtest)

运行 `composer test` 前，请将`.env.test.template`重命名为`.env.test`存放测试需要的变量
Before running `composer test`, rename `.env.test.template` to `env.test` to store variables needed for testing
[![.env.test example](https://camo.githubusercontent.com/b8b3d0ca1e244309e3d5cb401bd5f9504fa0f65b3b83206a9bba18a13cfdbf8a/68747470733a2f2f73322e6c6f6c692e6e65742f323032322f30392f31302f3165374778536c71757954506452582e6a7067)](https://camo.githubusercontent.com/b8b3d0ca1e244309e3d5cb401bd5f9504fa0f65b3b83206a9bba18a13cfdbf8a/68747470733a2f2f73322e6c6f6c692e6e65742f323032322f30392f31302f3165374778536c71757954506452582e6a7067)

Example 示例
----------

[](#example-示例)

### Common 通用

[](#common-通用)

```
$yzhanGateway = new YZhanGateway('Common');
$res = $yzhanGateway->request(array(
  'method' => 'GET',
  'url' => 'https://animechan.vercel.app/api/random'
));
```

### Use Cache 使用缓存

[](#use-cache-使用缓存)

Cache Results for 86400 seconds

```
$yzhanGateway = new YZhanGateway('Common');
$res = $yzhanGateway->cache()->request(array(
  'method' => 'GET',
  'url' => 'https://animechan.vercel.app/api/random',
  'cache' => array(
    'maxAge' => 86400
  )
));
```

### Clear Cache 清理缓存

[](#clear-cache-清理缓存)

Cache Results for 86400 seconds

```
$yzhanGateway = new YZhanGateway('Common');
$params = array(
  'method' => 'GET',
  'url' => 'https://animechan.vercel.app/api/random',
  'cache' => array(
    'maxAge' => 86400
  )
);
$res = $yzhanGateway->cache()->request($params);
if ($res === null) { // If results is bad, using getCache to get the yzhanCache instance
  $yzhanGateway->getCache()->delete($yzhanGateway->getKey($params)); // Delete, set by the key
}
```

### BaiduCloud 百度智能云

[](#baiducloud-百度智能云)

Purge Files by urls in Biadu Cloud CDN.

```
$yzhanGateway = new YZhanGateway('BaiduCloud', array(
  'accessKey' => $_ENV['BAIDUCLOUD_ACCESSKEY'],
  'secretKey' => $_ENV['BAIDUCLOUD_SECRETKEY']
));
$res = $yzhanGateway->request(array(
  'method' => 'POST',
  'url' => 'http://cdn.baidubce.com/v2/cache/purge',
  'postFields' => array(
    'tasks' => array(
      array('url' => $_ENV['BAIDUCLOUD_TEST_URL'])
    )
  )
));
```

### Cloudflare

[](#cloudflare)

Purge Files by urls (&lt;= 30) in Cloudflare.

```
$yzhanGateway = new YZhanGateway('Cloudflare', array(
  'apiToken' => $_ENV['CLOUDFLARE_APITOKEN']
));
$res = $yzhanGateway->request(array(
  'method' => 'POST',
  'url' => 'https://api.cloudflare.com/client/v4/zones/' . $_ENV['CLOUDFLARE_REGION_ID'] . '/purge_cache',
  'postFields' => array(
    'files' => array($_ENV['CLOUDFLARE_TEST_URL'])
  )
));
```

### Github

[](#github)

Get user's recent activities.

```
$yzhanGateway = new YZhanGateway('Github', array(
  'accessToken' => $_ENV['GITHUB_ACCESS_TOKEN'],
  'userAgent' => $_ENV['GITHUB_USER_NAME']
));
$res = $yzhanGateway->request(array(
  'method' => 'GET',
  'url' => 'https://api.github.com/users/' . $_ENV['GITHUB_USER_NAME'] . '/events'
));
```

### OpenAI

[](#openai)

Chat using text-davinci

```
$yzhanGateway = new YZhanGateway('OpenAI', array(
  'apiKey' => $_ENV['OPENAI_APIKEY'],
  // 'organization' => $_ENV['OPENAI_ORGANIZATION'] // Optional
));
$res = $yzhanGateway->request(array(
  'method' => 'POST',
  'url' => 'https://api.openai.com/v1/completions',
  'postFields' => array(
    'model' => 'text-davinci-003',
    'prompt' => 'Hello',
    'temperature'=> 0 // Optional, 0 means the most certain results
  )
));
```

### TencentCloud 腾讯云

[](#tencentcloud-腾讯云)

Get CVM list

```
$yzhanGateway = new YZhanGateway('TencentCloud', array(
  'secretId' => $_ENV['TENCENTCLOUD_SECRET_ID'],
  'secretKey' => $_ENV['TENCENTCLOUD_SECRET_KEY']
));
$res = $yzhanGateway->request(array(
  'method' => 'POST',
  'url' => 'https://cvm.tencentcloudapi.com',
  'action' => 'DescribeInstances',
  'version' => '2017-03-12',
  'region' => 'ap-guangzhou',
  'postFields' => array(
    'Limit' => 1,
    'Filters' => array(
      array('Values' => array('未命名'), 'Name' => 'instance-name')
    ),
  )
));
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity47

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

Every ~125 days

Recently: every ~187 days

Total

7

Last Release

586d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/186219fca45bab5c5266d7c1f22c79c217f21ba7ada3142795a8ae69f95be0f6?d=identicon)[mantoufan](/maintainers/mantoufan)

---

Top Contributors

[![mantoufan](https://avatars.githubusercontent.com/u/4961543?v=4)](https://github.com/mantoufan "mantoufan (14 commits)")

---

Tags

sdkcloudflarecdnapi-gatewayPurge CacheBaidu Cloud

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mantoufan-yzhangateway/health.svg)

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

###  Alternatives

[cloudinary/cloudinary_php

Cloudinary PHP SDK

39913.5M90](/packages/cloudinary-cloudinary-php)[vectorface/whip

A PHP class for retrieving accurate IP address information for the client.

3781.1M14](/packages/vectorface-whip)[hardcastle/xrpl_php

PHP SDK / Client for the XRP Ledger

129.7k5](/packages/hardcastle-xrpl-php)

PHPackages © 2026

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