1. Go to this page and download the library: Download kontirol/apidoc 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/ */
kontirol / apidoc example snippets
namespace App\Api\Controller;
class UserController
{
/**
* 分页返回用户列表。
*
* @name 用户列表
* @route /api/user/list
* @method GET
* @tag 用户
* @auth bearer
* @param int page=1 页码
* @param int size=10 每页数量
* @param string keyword 昵称关键字
* @response 200 {"code":200,"message":"ok","data":{"total":42,"list":[{"id":1,"nickname":"张三"}]}}
*/
public function index(): array
{
return [];
}
/**
* @name 用户详情
* @route /api/user/{id}
* @method GET
* @tag 用户
* @auth bearer
* @param int! id 用户 ID
* @response 200 {"code":200,"message":"ok","data":{"id":1,"nickname":"张三"}}
* @response 404 {"code":404,"message":"用户不存在"}
*/
public function detail(int $id): array
{
return [];
}
}