PHPackages                             myzero1/yii2-fast-api - 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. [API Development](/categories/api)
4. /
5. myzero1/yii2-fast-api

ActiveLibrary[API Development](/categories/api)

myzero1/yii2-fast-api
=====================

A component to develop api faster on yii2 framework

1.0.0(8y ago)0597↓58.3%BSD-3-ClausePHP

Since Nov 20Pushed 8y agoCompare

[ Source](https://github.com/myzero1/yii2-fast-api)[ Packagist](https://packagist.org/packages/myzero1/yii2-fast-api)[ RSS](/packages/myzero1-yii2-fast-api/feed)WikiDiscussions master Synced 4w ago

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

yii2-fast-api
-------------

[](#yii2-fast-api)

yii2-fast-api是一个Yii2框架的扩展，用于配置完善Yii2，以实现api的快速开发。 此扩展默认的场景是APP的后端接口开发，因此偏向于实用主义，并未完全采用restfull的标准，方便前端开发处理接口数据以及各种异常。

### Installation

[](#installation)

#### 使用 Composer 安装

[](#使用-composer-安装)

- 在项目中的 `composer.json` 文件中添加依赖：

```
"require": {
    "deepziyu/yii-fast-api": "*"
}
```

- 执行 `$ php composer.phar update` 或 `$ composer update` 进行安装。
- 在配置文件中（ Yii2 高级版为 main.php，Yii2 基础版为 web.php ）注入 fast-api 的配置：

```
// $config 为你原本的配置
$config = yii\helpers\ArrayHelper::merge(
    $config,
    \deepziyu\yii\rest\Controller::getConfig()
);

return $config;
```

### Usage

[](#usage)

- 建立控制器

```
class YourController extends deepziyu\yii\rest\Controller
{
    /**
     * 示例接口
     * @param int $id 请求参数
     * @return string version api版本
     * @return int yourId 你的请求参数
     */
    public function actionIndex($id)
    {
        return ['version'=>'1.0.0','yourId'=>$id];
    }
}

```

- 发送请求看看

正常请求

```
POST /your/index HTTP/1.1
Host: yoursite.com
Content-Type: application/json

{"id":"10"}

```

返回

```
{
    "code": 200,
    "data": {
        "version": "1.0.0",
        "yourId": "10"
    },
    "message": "OK"
}
```

缺少参数的请求

```
POST /your/index HTTP/1.1
Host: yoursite.com
Content-Type: application/json

```

返回错误

```
{
    "code": 400,
    "data": {},
    "message": "缺少参数：id"
}
```

- 查看自动生成的Api文档

http ://yoursite.com/route/api/index

[![mahua](https://camo.githubusercontent.com/9dff34ec679c1d5a434428ee68afed8ba1a3d89eca325a5a5d7089105b3ee249/687474703a2f2f6f6b30726a71336a7a2e626b742e636c6f7564646e2e636f6d2f515125453625383825414125453525394225424532303137303131393136353330302e706e67)](https://camo.githubusercontent.com/9dff34ec679c1d5a434428ee68afed8ba1a3d89eca325a5a5d7089105b3ee249/687474703a2f2f6f6b30726a71336a7a2e626b742e636c6f7564646e2e636f6d2f515125453625383825414125453525394225424532303137303131393136353330302e706e67)

### Words In The End

[](#words-in-the-end)

感谢@暗夜在火星 的PhalApi项目，为此Yii2扩展提供设计的思路。

### TODO

[](#todo)

- 更完善的文档指南
- Signature 过滤器插件
- 限流插件的使用
- RequestID 以及日志存储追踪的参考

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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

3144d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/myzero1-yii2-fast-api/health.svg)

```
[![Health](https://phpackages.com/badges/myzero1-yii2-fast-api/health.svg)](https://phpackages.com/packages/myzero1-yii2-fast-api)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[skeeks/yii2-google-api

Component for work with google api based on google/apiclient

1143.6k1](/packages/skeeks-yii2-google-api)[apexwire/yii2-restclient

Tools to use API as ActiveRecord for Yii2

133.5k](/packages/apexwire-yii2-restclient)

PHPackages © 2026

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