PHPackages                             tmecareer/yii-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. tmecareer/yii-fast-api

ActiveLibrary[API Development](/categories/api)

tmecareer/yii-fast-api
======================

A component to develop api faster on yii2 framework

1.0.0(4y ago)00BSD-3-ClausePHP

Since Aug 20Pushed 4y agoCompare

[ Source](https://github.com/tmecareer/yii2-fast-api)[ Packagist](https://packagist.org/packages/tmecareer/yii-fast-api)[ RSS](/packages/tmecareer-yii-fast-api/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (1)Versions (3)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

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

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 ~0 days

Total

2

Last Release

1777d ago

Major Versions

0.2.2 → 1.0.02021-08-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/e4e7aa0406a7a9a8f5c941b0ac9a5f2db65926be26c9e0736986940c115083b4?d=identicon)[wwt142](/maintainers/wwt142)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/tmecareer-yii-fast-api/health.svg)

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

###  Alternatives

[craftcms/cms

Craft CMS

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

Component for work with google api based on google/apiclient

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

Tools to use API as ActiveRecord for Yii2

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

PHPackages © 2026

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