PHP code example of mumbaicat / makeapidoc
1. Go to this page and download the library: Download mumbaicat/makeapidoc 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/ */
mumbaicat / makeapidoc example snippets
/**
* 获取所有列表
* @url api.php/index/index/all
* @method POST
* @param integer $page 页数
* @param integer $limit 每页个数
* @return integer $code 状态码
* @return string $msg 返回消息
*/
public function all($page,$limit){
// 地址中有三个占位符写法
// {url}/api.php/index/{controller}/{action}
// {url} 会自动替换成设置的域名 $doc->url = 'xxx'; 来设置。
// {action} 会自动换成对应的方法名
// {controller} 会自动换成文件名(大驼峰会转成匈牙利)。
// --------------------------------
// 默认是文件名和方法名都开启大驼峰转换
// 文件名是大写字母出现1次以及以上就转换
// 方法名是大写字母出现2次以及以上就转换
// 可以通过下面方法去改变,参数1是文件名,参数2是方法名
// $doc->setChange(true,true);
// $doc->setTime(1,2);
}
/**
* 获取我的列表
* @url api.php/index/index/my_list
* @method GET
* @return json json {'code':200,'msg':'json示例'}
*/
public function my_list($page,$limit){
.....
}
/**
* 获取我的名称
* @url api.php/index/index/get_my_name
* @method GET
* @return string 名称
*/
public function get_my_name(){
.....
}
/**
* 添加数据
* @url api.php/index/index/insert
* @method GET
* @param string $name 姓名
* @param string $age 年龄
* @return inetger $code 状态码
*/
public function insert(){
.....
}