{"id":31064908,"url":"https://github.com/pkg6/php-apidoc","last_synced_at":"2026-01-20T16:33:28.131Z","repository":{"id":295289290,"uuid":"989701153","full_name":"pkg6/php-apidoc","owner":"pkg6","description":"Generate documentation for php API based application. No dependency. No framework required.","archived":false,"fork":false,"pushed_at":"2025-06-09T06:44:50.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-15T15:09:13.155Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/pkg6/apidoc","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pkg6.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-24T16:39:43.000Z","updated_at":"2025-05-25T12:58:45.000Z","dependencies_parsed_at":"2025-05-24T18:01:45.337Z","dependency_job_id":"dde227ee-23ea-46d0-92ae-4d49af62e77a","html_url":"https://github.com/pkg6/php-apidoc","commit_stats":null,"previous_names":["pkg6/php-apidoc"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/pkg6/php-apidoc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkg6%2Fphp-apidoc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkg6%2Fphp-apidoc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkg6%2Fphp-apidoc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkg6%2Fphp-apidoc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pkg6","download_url":"https://codeload.github.com/pkg6/php-apidoc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkg6%2Fphp-apidoc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28607285,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T16:10:39.856Z","status":"ssl_error","status_checked_at":"2026-01-20T16:10:39.493Z","response_time":117,"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":"2025-09-15T15:05:45.616Z","updated_at":"2026-01-20T16:33:28.115Z","avatar_url":"https://github.com/pkg6.png","language":"PHP","readme":"# PHP-ApiDoc\n\n**为基于 PHP 的 API 应用生成文档**\n 无需依赖框架，无需额外依赖。\n\n------\n\n## 📋 环境要求\n\n- PHP \u003e= 5.3.2\n\n## 📦 安装\n\n使用 Composer 安装：\n\n```\ncomposer require pkg6/apidoc\n```\n\n## 🚀 使用方法\n\n在你的类和方法上使用注解：\n\n~~~\nnamespace Pkg6\\Apidoc\\Tests\\TestClasses;\n\nclass User\n{\n    /**\n     * @ApiDescription(section=\"User\", description=\"获取用户信息\")\n     * @ApiMethod(type=\"get\")\n     * @ApiRoute(name=\"/user/get/{id}\")\n     * @ApiParams(name=\"id\", type=\"integer\", nullable=false, description=\"用户ID\")\n     * @ApiParams(name=\"data\", type=\"object\", sample=\"{'user_id':'int','user_name':'string','profile':{'email':'string','age':'integer'}}\")\n     * @ApiReturnHeaders(sample=\"HTTP 200 OK\")\n     * @ApiReturn(type=\"object\", sample=\"{\n     *   'transaction_id':'int',\n     *   'transaction_status':'string'\n     * }\")\n     */\n    public function get() {}\n\n    /**\n     * @ApiDescription(section=\"User\", description=\"创建新用户\")\n     * @ApiMethod(type=\"post\")\n     * @ApiRoute(name=\"/user/create\")\n     * @ApiParams(name=\"username\", type=\"string\", nullable=false, description=\"用户名\")\n     * @ApiParams(name=\"email\", type=\"string\", nullable=false, description=\"邮箱\")\n     * @ApiParams(name=\"password\", type=\"string\", nullable=false, description=\"密码\")\n     * @ApiParams(name=\"age\", type=\"integer\", nullable=true, description=\"年龄\")\n     */\n    public function create() {}\n}\n\n~~~\n\n## ⚙️ 生成 API 文档\n\n~~~\n\u003c?php\n\nuse Pkg6\\Apidoc\\Builder;\n\nrequire 'vendor/autoload.php';\n\n$classes = array(\n    \"Pkg6\\Apidoc\\Tests\\TestClasses\\User\",\n    \"Pkg6\\Apidoc\\Tests\\TestClasses\\Article\"\n);\n\n$output_file = 'api.html'; // defaults to index.html\ntry {\n    $builder = new Builder($classes, \".\", 'Api Title', $output_file);\n    $builder-\u003egenerate();\n} catch (Exception $e) {\n    echo 'There was an error generating the documentation: ', $e-\u003egetMessage();\n}\n~~~\n\n然后通过命令行执行该文件：\n\n~~~\nphp apidoc.php\n~~~\n\n生成的API文档将保存在 `api.html` 。\n\n## 🧩 支持的注解方法\n\n目前支持以下注解：\n\n- `@ApiDescription(section=\"...\", description=\"...\")`\n- `@ApiMethod(type=\"get|post|put|delete|patch\")`\n- `@ApiRoute(name=\"...\")`\n- `@ApiParams(name=\"...\", type=\"...\", nullable=..., description=\"...\", [sample=\"...\"])`\n- `@ApiHeaders(name=\"...\", type=\"...\", nullable=..., description=\"...\")`\n- `@ApiReturnHeaders(sample=\"...\")`\n- `@ApiReturn(type=\"...\", sample=\"...\")`\n- `@ApiBody(sample=\"...\")`\n\n## 💡 小技巧\n\n如果你希望展示复杂对象的输入示例，可以使用 `@ApiParams` 并设置 `type=object|array|array(object)`，例如：\n\n~~~\n@ApiParams(\n    name=\"data\", \n    type=\"object\", \n    sample=\"{'user_id':'int','profile':{'email':'string','age':'integer'}}\"\n)\n~~~\n\n## 🙏 感谢\n\n本项目灵感来源并参考了优秀的开源项目 [calinrada/php-apidoc](https://github.com/calinrada/php-apidoc)，在此致以诚挚感谢 🙌。\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkg6%2Fphp-apidoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpkg6%2Fphp-apidoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkg6%2Fphp-apidoc/lists"}