Download the PHP package tangwei/apidocs without Composer

On this page you can find all versions of the php package tangwei/apidocs. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package apidocs

PHP Hyperf API Docs

Latest Stable Version Total Downloads License PHP Version

English | 中文

基于 Hyperf 框架的 Swagger/OpenAPI 文档自动生成组件,支持 Swoole/Swow 引擎,为您提供优雅的 API 文档解决方案。

✨ 特性

📋 环境要求

💡 使用须知

📦 安装

默认使用 Swagger UI,推荐安装 Knife4j UI(可选):

🚀 快速开始

1. 发布配置文件

配置文件将发布到 config/autoload/api_docs.php

2. 基础配置

完整配置文件示例:config/autoload/api_docs.php

完整配置说明(点击展开)

3. 启动服务

📖 使用指南

基础示例

1. 定义 DTO 类

2. 编写控制器

🎨 注解参考

控制器注解

#[Api] - 控制器标签

#[ApiOperation] - API 操作

#[ApiResponse] - 响应定义

泛型支持示例:

PHP 暂不支持泛型,可通过 #[ApiVariable] 实现:

控制器使用:

参数注解

#[RequestBody] - Body 参数

获取 POST/PUT/PATCH 请求的 JSON body 参数:

#[RequestQuery] - Query 参数

获取 URL 查询参数(GET 参数):

#[RequestFormData] - 表单参数

获取表单数据(multipart/form-data):

#[RequestHeader] - 请求头参数

获取请求头信息:

⚠️ 注意:一个方法不能同时注入 RequestBodyRequestFormData

属性注解

#[ApiModelProperty] - 属性描述

#[ApiHeader] - 请求头定义

#[ApiSecurity] - 安全认证

优先级:方法 > 类 > 全局

✅ 数据验证

内置验证注解

组件提供丰富的验证注解支持:

💡 提示:只需在控制器方法参数中添加 #[Valid] 注解即可启用验证

自定义验证

使用 Validation 注解

自定义验证注解

使用自定义验证:

🔧 高级特性

数组类型支持

方法一:使用 PHPDoc

方法二:使用 ArrayType 注解

嵌套对象

枚举支持

全局响应格式

配置全局响应包装类:

定义全局响应类:

文件上传

🎭 多种 UI 界面

访问不同的 UI 界面:

⚙️ 配置参考

DTO 数据映射

api-docs 依赖 DTO 组件,更多详情请查看 DTO 文档

#[Dto] 注解

标记为 DTO 类:

#[JSONField] 注解

用于设置属性的别名:

RPC 支持

返回 PHP 对象

aspects.php 中配置:

当框架导入 symfony/serializer (^5.0)symfony/property-access (^5.0) 后,在 dependencies.php 中配置映射关系:

💡 最佳实践

1. DTO 类设计

2. 控制器设计

3. 安全性

4. 性能优化

📚 常见问题

Q: 文档没有生成?

A: 检查以下几点:

  1. 配置文件中 enable 是否为 true
  2. 查看日志是否有错误信息

Q: 如何定义数组类型?

A: 使用 PHPDoc 注释或 ArrayType 注解:

Q: 如何隐藏某些接口?

A: 使用 hidden 参数:

Q: 如何自定义响应格式?

A: 使用 ApiResponse 注解或配置全局响应类:

Q: 支持哪些验证规则?

A: 支持所有 Hyperf Validation 规则。详见 Hyperf 验证器文档

Q: AutoController 注解支持吗?

A: 支持,但只会收集 POST 方法。建议使用标准路由注解以获得更好的文档生成效果。

📖 示例项目

完整示例请参考 example 目录

🔗 相关链接


如果这个项目对你有帮助,请给个 ⭐ Star!


All versions of apidocs with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
tangwei/dto Version ~3.2.0
zircote/swagger-php Version ^5.1||^6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tangwei/apidocs contains the following files

Loading the files please wait ...