Skip to content
Yi Xian edited this page Sep 27, 2016 · 5 revisions

此功能现在默认是开启的, 将允许通过接口(http://your-domain.com/api/apis/)获取接口本身的文档信息,你可以将此网址发送给需要调用此Api的相关功能的开发者,文档中列出了接口的详细调用方式级相关参数等,形式如下:

<?php
/**
 * doc class
 * @path("doc_sample")
 */
class DocSample
{
 /**
 * doc func
 * @route({"POST", "path1"}) doc path1
 * @route({"POST", "path2"})
 * doc path2
 * @param({"arg0", "$._GET.arg0"}) doc arg0
 * @param({"arg1", "$._POST.arg1"}) doc arg1
 * @return({"body"}) doc return body
 * @return({"status", "200 OK"}) doc return status
 * @return({"header", "$header0"}) doc return $header0
 * @return({"cookie", "token", "$cookie0"}) doc return $cookie0
 * @throws({"Exception", "status", "500 Internal Server Error"}) doc Exception
 */
 public function func($arg0, $arg1, &$header0, &$cookie0){

 }
 /**
 * @inject("$.path[2]")
 * doc common
 */
 private $common;
}

生成的文档如下:

开启方式为设置" phprs\Router"的属性"export_apis"为true 目前支持文档化的注释有:

@route
@path
@return: status,header,cookie, body,res
@throws:status,header,cookie, body,res
@param: $.path[*], $._SERVER.HTTP_X_*, $._GET.*, $._POST.*
Clone this wiki locally