PHPackages                             curselby/tp5-doc - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. curselby/tp5-doc

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

curselby/tp5-doc
================

A doc package require thinkphp5

v1.0.0(9y ago)1231Apache-2.0PHP

Since Apr 16Pushed 9y agoCompare

[ Source](https://github.com/curselby/tp5-doc)[ Packagist](https://packagist.org/packages/curselby/tp5-doc)[ RSS](/packages/curselby-tp5-doc/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Tp5-Doc
=======

[](#tp5-doc)

基于 thinkphp5 的doc文档扩展

\[TOC\]

说明
--

[](#说明)

thinkphp5编写的自动生成文档功能；

- 文档生成

> 简洁，优雅，不需要额外的文档工具;

安装
--

[](#安装)

- 如果想在你的TP5项目中使用,那么可以直接使用

```
composer require curselby/tp5-doc

```

- 如果是新项目先要创建tp5项目,然后再require

```
composer create-project topthink/think api  --prefer-dist
composer require curselby/tp5-doc

```

- 使用生成文档 需要在public/static/ 下 安装hadmin

```
cd /public/static/
git clone  https://git.oschina.net/curselby/hadmin.git

```

使用
--

[](#使用)

1. 创建Doc文档显示控制器 wiki 继承 Tp5Doc\\doc\\Doc;
2. 配置路由

```
   'wiki'=>'demo/Wiki/index',//文档
```

3.配置文档显示目录

```
    /**
     * 获取文档
     * @return mixed
     */
    public static function getApiDocList()
    {
        //todo 可以写配置文件或数据
        $apiList = Config::get('api_doc');
        return $apiList;
    }
```

> 可以改写次方法以存储以无限级的方式，为了方便采用的是配置方式

tp5 增加额外配置 创建application/extra/api\_doc.php 文件

```
return [
    '1' => ['name' => '测试文档', 'id' => '1', 'parent' => '0', 'class'=>'','readme' =>''],//下面有子列表为一级目录
    '2' => ['name' => '获取权限', 'id' => '2', 'parent' => '1', 'class'=>'','readme' => '/doc/md/auth.md'],//没有接口的文档，加载markdown文档
    '3' => ['name' => '用户接口', 'id' => '3', 'parent' => '1', 'readme' => '','class'=>\app\test\controller\User::class],//User接口文档
];
```

[![wiki](https://raw.githubusercontent.com/liushoukun/dawn-api-demo/master/public/doc/images/wiki.png)](https://raw.githubusercontent.com/liushoukun/dawn-api-demo/master/public/doc/images/wiki.png)

参数必须备注作用nametrue接口列表名称显示列表名称idtrue主键生成列表所用parenttrue生成列表所用classtrue接口位置用于生成具体接口文档readmetruemarkdown可以生成没有接口的文档，比如一些说明 module和controller为空,readme填文档路径3.具体接口文档配置

- 接口描述部分(类文件的注释)

```
/**
 * Class User
 * @title 用户接口
 * @url /v1/user
 * @desc  有关于用户的接口
 * @version 1.0
 * @readme /doc/md/user.md
 */
class User extends Base{}
```

参数必须备注作用titletrue接口标题显示列表名称urltrue请求地址用户显示desctrue接口描述显示描述versionfalse版本号版本号readmefalsemarkdown文档可以编写信息文档[![ClassDoc](https://raw.githubusercontent.com/liushoukun/dawn-api-demo/master/public/doc/images/demo12.png)](https://raw.githubusercontent.com/liushoukun/dawn-api-demo/master/public/doc/images/demo12.png)

- 具体接口文档

1. 接口描述信息(注释填写)

```
       /**
        * @title 获取用户信息
        * @desc 获取用户信息
        * @readme /doc/md/method.md
        */
      public function getResponse(\think\Request $request){}
```

参数必须备注作用titletrue接口标题显示列表名称desctrue接口描述显示描述readmefalsemarkdown文档可以编写信息文档2.请求参数

```
    /**
     * 参数规则
     * @name 字段名称
     * @type 类型
     * @require 是否必须
     * @default 默认值
     * @desc 说明
     * @range 范围
     * @return array
     */
    public static function getRules()
    {
        $rules = [
                //共用参数
                'all'=>[
                    'time'=> ['name' => 'time', 'type' => 'int', 'require' => 'true', 'default' => '', 'desc' => '时间戳', 'range' => '',]
                ],

                'get'=>[
                    'id' => ['name' => 'id', 'type' => 'int', 'require' => 'true', 'default' => '', 'desc' => '用户id', 'range' => '',]
                ],
                'post'=>[
                    'username' => ['name' => 'username', 'type' => 'string', 'require' => 'true', 'default' => '', 'desc' => '用户名', 'range' => '',],
                    'age' => ['name' => 'age', 'type' => 'int', 'require' => 'true', 'default' => '18', 'desc' => '年龄', 'range' => '0-200',],
                ]
        ];
        //合并父级类参数
        return array_merge(parent::getRules(),$rules);
    }
```

[![data](https://raw.githubusercontent.com/liushoukun/dawn-api-demo/master/public/doc/images/demo14.png)](https://raw.githubusercontent.com/liushoukun/dawn-api-demo/master/public/doc/images/demo14.png)

3. 返回参数(注释填写)

```
     * @return int id ID
     * @return string username 错误信息
     * @return int age 年龄
```

参数必须备注第一个参数true类型第二个参数true参数名第三个参数true参数说明> 类型填写规则

```
'string'    => '字符串',
'int'       => '整型',
'float'     => '浮点型',
'boolean'   => '布尔型',
'date'      => '日期',
'array'     => '数组',
'fixed'     => '固定值',
'enum'      => '枚举类型',
'object'    => '对象',
```

[![return](https://raw.githubusercontent.com/liushoukun/dawn-api-demo/master/public/doc/images/demo15.png)](https://raw.githubusercontent.com/liushoukun/dawn-api-demo/master/public/doc/images/demo15.png)

整体效果 [![all](https://raw.githubusercontent.com/liushoukun/dawn-api-demo/master/public/doc/images/demo16.png)](https://raw.githubusercontent.com/liushoukun/dawn-api-demo/master/public/doc/images/demo16.png)[![all](https://raw.githubusercontent.com/liushoukun/dawn-api-demo/master/public/doc/images/demo17.png)](https://raw.githubusercontent.com/liushoukun/dawn-api-demo/master/public/doc/images/demo17.png)[![all](https://raw.githubusercontent.com/liushoukun/dawn-api-demo/master/public/doc/images/demo18.png)](https://raw.githubusercontent.com/liushoukun/dawn-api-demo/master/public/doc/images/demo18.png)

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity63

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3362d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1884631?v=4)[Boyce](/maintainers/Boyce)[@boyce](https://github.com/boyce)

### Embed Badge

![Health badge](/badges/curselby-tp5-doc/health.svg)

```
[![Health](https://phpackages.com/badges/curselby-tp5-doc/health.svg)](https://phpackages.com/packages/curselby-tp5-doc)
```

###  Alternatives

[topthink/think-captcha

captcha package for thinkphp

117958.5k73](/packages/topthink-think-captcha)[topthink/think-worker

workerman extend for thinkphp

202233.1k9](/packages/topthink-think-worker)[yunwuxin/think-cron

计划任务

16816.9k](/packages/yunwuxin-think-cron)[zzstudio/think-addons

The ThinkPHP6 Addons Package

1518.7k](/packages/zzstudio-think-addons)[topthink/think-annotation

Annotation For ThinkPHP

4832.9k8](/packages/topthink-think-annotation)[liliuwei/thinkphp-jump

适用于thinkphp6.0的跳转扩展

2875.9k1](/packages/liliuwei-thinkphp-jump)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
