{"id":20144725,"url":"https://github.com/widuu/think-api","last_synced_at":"2026-05-13T09:05:43.625Z","repository":{"id":57080589,"uuid":"392734789","full_name":"widuu/think-api","owner":"widuu","description":"tp6.0 api 文档生成工具","archived":false,"fork":false,"pushed_at":"2021-08-07T09:00:21.000Z","size":36,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-27T08:17:20.509Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/widuu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-04T15:14:29.000Z","updated_at":"2021-08-07T08:52:56.000Z","dependencies_parsed_at":"2022-08-24T14:57:37.944Z","dependency_job_id":null,"html_url":"https://github.com/widuu/think-api","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/widuu/think-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widuu%2Fthink-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widuu%2Fthink-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widuu%2Fthink-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widuu%2Fthink-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/widuu","download_url":"https://codeload.github.com/widuu/think-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widuu%2Fthink-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32975183,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T06:31:55.726Z","status":"ssl_error","status_checked_at":"2026-05-13T06:31:51.336Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T22:11:52.655Z","updated_at":"2026-05-13T09:05:43.589Z","avatar_url":"https://github.com/widuu.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# think-api\n\n\u003e Thinkphp 6 api 文档生成系统\n\n### 安装\n\n```\ncomposer require widuu/think-api\n```\n\n### 配置\n\n```\nreturn [\n    // api 名称,生成文档的头部显示文字\n    'api_name'           =\u003e '测试API',\n    // api 接口请求地址\n    'api_url'            =\u003e '',\n    // api 作者\n    'api_author'         =\u003e '',\n    // 默认语言，其它语言在 vendor/widuu/think-api/src/lang 下添加对应的语言\n    'api_language'       =\u003e 'zh-cn',\n    // 将哪个模块作为api使用，如果没有安装多应用模块，这个是 controller 名称\n    'module_name'        =\u003e 'index',\n    // api 路由，注册路由显示 api 文档\n    'api_route'          =\u003e '/api',\n    // api 路由绑定域名，显示文档的域名\n    'api_route_domain'   =\u003e '',\n    // api 自动生成地址的后缀\n    'api_url_suffix'      =\u003e false,\n    // api 排除类中的方法，譬如你有个 init 等等\n    'api_method_fileter'  =\u003e [],\n    // api 缓存名称，目录缓存，如果为空缓存，如果不为空就缓存\n    'api_cache_name'     =\u003e 'THINK_APIDOC_CACHE',\n    // 附加类库，将其它类库显示文档\n    'extend_class'       =\u003e [\n\n    ],\n];\n```\n\n### 使用\n\n\u003e 生成静态文档，使用 php think api 参数如下\n\n```\n  -u, --url[=URL]            default api url [default: \"\"]\n  -m, --module[=MODULE]      module name like index [default: \"index\"]\n  -o, --outfile[=OUTFILE]    output index file name [default: \"api.html\"]\n  -f, --force[=FORCE]        force override general file [default: false]\n  -t, --name[=NAME]          document api name [default: \"测试API\"]\n  -c, --class[=CLASS]        extend class (multiple values allowed)\n  -l, --language[=LANGUAGE]  language [default: \"zh-cn\"]\n```\n\n\u003e 实时访问通过配置中定义的路由就可以直接访问了\n\n### 注释说明\n\n#### 类注解\n\n|名称|说明|实例|\n|:-----|:-----|:-----|\n|@ApiTitle|类说明，如果不存在分组（@ApiSector）标题当成分组| @ApiTitle(\"测试类\")|\n|@ApiSector|分组，如果类内部方法没有此注解，所有函数都归属于此分组| @ApiSector(\"测试分组\")|\n|@ApiInternal|内部文档，禁止解析，使用之后此类不会被解析|@ApiInternal(true)|\n|@ApiWeigh|排序，数字越大，排序越靠上|@ApiWeigh(10)|\n\n#### 方法注解\n\n\u003e 注只解析 `public` 方法，并且跳过 `__construct` 方法，如果想要跳过哪些方法，可以在 `config/api.php` 中的 `api_method_fileter` 中添加方法名称来跳过注解\n\n|名称|说明|实例|\n|:-----|:-----|:-----|\n|@ApiInternal|内部文档，禁止解析，使用之后此方法不会被解析|@ApiInternal (true)|\n|@ApiTitle|方法说明，如果不存在，会匹配注释的文档信息匹配中文和英文信息，不能有符号，匹配不成功就是英文名称| @ApiTitle(\"测试方法\")|\n|@ApiSector|分组，如果不存在分组，则属于类内部分组| @ApiSector (\"测试分组\")|\n|@ApiRoute|路由，如果是指定的tinkphp的控制器，可以为空自动解析，但是如果其他类或者伪静态一定要指定，路由建议用\"\"注释,防止解析{}符号|@ApiRoute (\"/index/test/{name}\")|\n|@ApiMethod|Api的请求方法，如果不存在就是 'GET' 方法|@ApiMethod(POST)|\n|@ApiContentType| Api 的 Content-type|@ApiMethod (\"multipart/form-data\")|\n|@ApiHeaders|请求头部信息，可以多个|@ApiHeaders (name=username, type=string, required=true, description=\"请求的用户名\")|\n|@ApiParams|请求的参数，可以多个|@ApiParams(name=\"name\", type=\"string\", required=true, description=\"方法名字\")|\n|@ApiReturnParams|返回参数说明，可以多个|@ApiReturnParams (name=\"code\", type=\"integer\", required=true, sample=\"0\", description=\"返回的状态\")|\n|@ApiReturnHeaders|返回头部，可以多个|@ApiReturnHeaders (name=\"token\", type=\"integer\", required=true, sample=\"xxxxxxxx\")|\n|@ApiReturn|返回结果示例,json中使用\"\",因为会解析{}|@ApiReturn (\"{'code':1,'msg':'返回成功','data':{'test':1}}\")|\n|@ApiBody|body正文|@ApiBody (\"body\")|\n|@ApiWeigh|排序，数字越大，排序越靠上|@ApiWeigh(10)|\n\n\n#### 示例\n\n```\n\u003c?php\n\n\nnamespace app\\index\\controller\\test;\n\n/**\n * @ApiTitle(\"测试API\")\n * @ApiWeigh (20)\n * Class Index\n * @package app\\index\\controller\\test\n */\nclass Index\n{\n    /**\n     * 测试方法\n     *\n     * @ApiTitle    (测试名称)\n     * @ApiSector   (测试分组)\n     * @ApiDescription   (测试描述信息)\n     * @ApiRoute    (\"/index/index.test/index/{name}\")\n     * @ApiContentType (\"multipart/form-data\")\n     * @ApiMethod   (POST)\n     * @ApiHeaders (name=username, type=string, required=true, description=\"请求的用户名\")\n     * @ApiBody   (测试正文)\n     * @ApiParams   (name=\"name\", type=\"string\", required=true, description=\"用户名\")\n     * @ApiReturnParams (name=\"code\", type=\"integer\", required=true, sample=\"0\", description=\"返回的状态\")\n     * @ApiReturnHeaders (name=\"token\", type=\"integer\", required=true, sample=\"xxxxxxxx\")\n     * @ApiReturn   (\"{\n     *  'code':'1',\n     *  'mesg':'返回成功'\n     * }\")\n     */\n    public function index()\n    {}\n\n    /**\n     * 方法测试\n     */\n    public function test()\n    {}\n\n    /**\n     * 跳过注解的方法\n     * @ApiInternal（true)\n     */\n    public function say()\n    {}\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiduu%2Fthink-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwiduu%2Fthink-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiduu%2Fthink-api/lists"}