klightsaber / yii2-doc-online

Yii2框架使用的在线文档库。

v2.0.2 2018-09-14 03:20 UTC

This package is auto-updated.

Last update: 2024-09-14 19:14:52 UTC


README

http://www.liyangweb.com

How to install?

composer require kaopur/yii2-doc-online

如何使用?

  1. 安装库。
  2. 创建一个新的模块配置到web.php,例如
    'modules' => [
        'doconline' => [
            'class' => 'Kaopur\yii2_doc_online\Module',
            'defaultRoute' => 'index', //默认控制器
            'appControllers' => true, //是否检测app\controllers命名空间下的控制器
            'suffix' => '', //api后缀
            'prefix' => '', //api前缀
            'modules' => [  //需要生成文档的模块命名空间
                'app\modules\admin\Module',
            ],
        ],
    ],
    
  3. 在浏览器中打开URL。 http://url.com?r=doconline

示例

代码如下

/**
 * 这是一个测试的Api
 * @desc 列举所有的注释格式
 * @param string $user_type |用户类型|yes|其他说明|
 * @param int $sex |性别|no|0:不限 1:男 2:女|
 * @return int status 操作码,0表示成功
 * @return array list 用户列表
 * @return int list[].id 用户ID
 * @return string list[].name 用户名字
 * @return string msg 提示信息
 * @exception 400 参数传递错误
 * @exception 500 服务器内部错误
 */
public function actionDemoapi($user_type, $sex)
{
    $result = [
        'status' => 0,
        'list' => [
            'id' => 1,
            'name' => 'kaopur'
        ],
        'msg' => 'OK'
    ];
    return \yii\helpers\Json::encode($result);
}

显示

image