PHPackages                             bestyii/yii2-gii-rest - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. bestyii/yii2-gii-rest

ActiveYii2-extension[HTTP &amp; Networking](/categories/http)

bestyii/yii2-gii-rest
=====================

RESTful generator for gii

0.0.2(6y ago)622.4k↓42.3%BSD-3-ClausePHP

Since Feb 29Pushed 6y ago3 watchersCompare

[ Source](https://github.com/bestyii/yii2-gii-rest)[ Packagist](https://packagist.org/packages/bestyii/yii2-gii-rest)[ RSS](/packages/bestyii-yii2-gii-rest/feed)WikiDiscussions master Synced 1mo ago

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

Yii2 RESTful generator for gii
==============================

[](#yii2-restful-generator-for-gii)

Gii 模块的REST代码生成器，包含Model和Controller。

代码注释文档包含OpenAPI Specification 规范的文档。

可配合 [Yii2 OpenApi Reader](https://github.com/bestyii/yii2-openapi-reader) 模块渲染出漂亮的api文档。

安装 Installation
---------------

[](#安装-installation)

通过 [composer](http://getcomposer.org/download/)安装.

项目中直接运行

```
php composer.phar require --prefer-dist bestyii/yii2-gii-rest "*"

```

or add

```
"bestyii/yii2-gii-rest": "*"

```

或者添加下面代码到 `composer.json`文件

使用 Usage
--------

[](#使用-usage)

在`config/web.php` 配置文件中，`gii`的配置部分增加模版：

```
$config['modules']['gii'] = [
        'class' => 'yii\gii\Module',

        'generators' => [ //自定义生成器
            'rest-model' => [ // generator name
                'class' => 'bestyii\giiRest\generators\model\Generator', // generator class
            ],
            'rest-crud' => [ // generator name
                'class' => 'bestyii\giiRest\generators\crud\Generator', // generator class
            ]
        ],
    ];
```

运行gii，可以看到增加了`REST Model Generator`和`REST CRUD Generator`两个生成器。

[![alt gii](demo.png "gii")](demo.png)

生成的代码示例：

示例 controller

```
