iguazoft/yii2-postman-generator
Composer 安装命令:
composer require iguazoft/yii2-postman-generator
包简介
Yii2 extension to generate Postman collections from PHPDoc annotations
README 文档
README
Extensión para Yii2 que genera colecciones de Postman automáticamente desde anotaciones PHPDoc.
Instalación
Vía Composer (recomendado)
composer require iguazoft/yii2-postman-generator
Instalación local
Añadir al composer.json:
{
"repositories": [
{
"type": "path",
"url": "packages/yii2-postman-generator"
}
],
"require": {
"iguazoft/yii2-postman-generator": "*"
}
}
Uso Rápido
1. Añadir anotaciones a tus controladores
<?php namespace app\controllers; use yii\rest\Controller; /** * @Postman\Collection("Mi API") * @Postman\Description("API REST de mi aplicación") */ class UserController extends Controller { /** * @Postman\Request("Listar usuarios") * @Postman\Folder("Usuarios") * @Postman\Method("GET") * @Postman\Path("/api/users") * @Postman\Auth("bearer", "{{token}}") */ public function actionIndex() { // ... } /** * @Postman\Request("Crear usuario") * @Postman\Folder("Usuarios") * @Postman\Method("POST") * @Postman\Path("/api/users") * @Postman\Auth("bearer", "{{token}}") * @Postman\Body({ * "name": "John Doe", * "email": "john@example.com" * }) */ public function actionCreate() { // ... } }
2. Generar la colección
php yii postman/generate
3. Opciones disponibles
# Especificar archivo de salida php yii postman/generate --output=docs/api.json # Escanear múltiples directorios php yii postman/generate --dirs=@app/controllers,@app/modules/api/controllers # Especificar nombre y URL base php yii postman/generate --name="Mi API" --baseUrl=http://api.example.com # Ver ayuda sobre anotaciones php yii postman/help
Anotaciones Disponibles
Anotaciones de Clase
| Anotación | Descripción |
|---|---|
@Postman\Collection("nombre") |
Nombre de la colección |
@Postman\Description("desc") |
Descripción de la colección |
@Postman\BaseUrl("url") |
URL base por defecto |
@Postman\Variable("key", "value") |
Variable de la colección |
Anotaciones de Método
| Anotación | Descripción | Requerido |
|---|---|---|
@Postman\Request("nombre") |
Nombre del request | ✅ Sí |
@Postman\Method("POST") |
Método HTTP | No (default: GET) |
@Postman\Path("/api/endpoint") |
Ruta del endpoint | No |
@Postman\Folder("Carpeta") |
Carpeta para agrupar | No |
@Postman\Description("desc") |
Descripción | No |
@Postman\Auth("bearer", "{{token}}") |
Autenticación | No |
@Postman\Body({...}) |
Body JSON | No |
@Postman\Header("key", "value") |
Header HTTP | No |
@Postman\Query("key", "value") |
Query parameter | No |
@Postman\Hidden |
Ocultar endpoint | No |
Ocultar Endpoints
Usa @Postman\Hidden para ocultar endpoints de la colección generada:
/** * @Postman\Request("Endpoint Interno") * @Postman\Hidden */ public function actionInterno() { }
Por defecto, los endpoints con @Postman\Hidden NO se incluyen en la colección.
Para incluir todos los endpoints (incluyendo los ocultos):
php yii postman/generate --include-hidden
# o
php yii postman/generate -a
Uso Programático
use iguazoft\postman\PostmanGenerator; $generator = new PostmanGenerator([ 'scanDirs' => [ '@app/controllers', '@app/modules/api/v1/controllers', ], 'collectionName' => 'Mi API', 'variables' => [ 'baseUrl' => 'http://localhost:8080', ], ]); // Guardar en archivo $generator->generate('@app/docs/api.postman_collection.json'); // O obtener como JSON $json = $generator->generateJson();
Licencia
MIT
iguazoft/yii2-postman-generator 适用场景与选型建议
iguazoft/yii2-postman-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「documentation」 「phpdoc」 「api」 「yii2」 「Postman」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 iguazoft/yii2-postman-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 iguazoft/yii2-postman-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 iguazoft/yii2-postman-generator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A simple tool for checking that your PHP classes and methods use PHPDocs (PHP DocBlocks Checker fork).
Bookdown.io With Bootswatch Styles And Prism Syntax Highlighting
Laravel package that generates RESTful API documentation in Markdown based on PHPDoc.
A PSR-7 compatible library for making CRUD API endpoints
Laravel API documentation generating tool
Validates PHPDoc @param and @return tags against method signatures
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-10