PHPDocumentor 是一个用PHP写的工具, 对于有规范注释的php程序, 它能够快速生成具有相互参照,索引等功能的API文档.
1,PHPDocumentor安装:(方式一)通过下载PHAR
https://phpdoc.org/phpDocumentor.phar
或下载从特定版本 https://github.com/phpDocumentor/phpDocumentor/releases。
得到 phpDocumentor.phar 文件,(需要大于7.2.1的php才能运行)
2,简单测试:
创一个文件夹doc/,写php文件测试(PHPDoc.php)
<?php
/**
* @package Doc
* @author heguanbiao
* @version 1.0.4
**/
namespace Doc;
class Doc{
/**
* @param array $user_info
* @return array
*/
public function user_info($user_info = array()){
$result = ["status" => 1];
return $result;
}
}
执行:(指定doc文件下的php, 将文档写入D:\php_doc1)
运行phpDocumentor时,有三个必不可少的命令行选项:
-d
指定要记录的项目目录。
-f
指定项目中要记录的一个或多个特定文件。
-t
指定文档将被写入的位置(也称为“目标文件夹”)
打开index.html
API文档
用phpDocumentor为自己的代码生成文档
简单的标签参考
@author --作者信息
@const --由define定义的常量
@deprecate --不建议使用的API
@global --全局变量
@package --包信息
@param --函数参数
@return --返回值
@see --参考函数
@since --引入时间
@static --静态变量
@var --类成员变量