PHP code example of kaopur / yii2-doc-online

1. Go to this page and download the library: Download kaopur/yii2-doc-online library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kaopur / yii2-doc-online example snippets


    'modules' => [
        'doconline' => [
            'class' => 'Kaopur\yii2_doc_online\Module',
            'defaultRoute' => 'index', //默认控制器
            'appControllers' => true, //是否检测app\controllers命名空间下的控制器
            'suffix' => '', //api后缀
            'prefix' => '', //api前缀
            'modules' => [  //需要生成文档的模块命名空间
                'app\modules\admin\Module',
            ],
        ],
    ],
    

/**
 * 这是一个测试的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);
}