samody/laravel-smart-postman-generator
Composer 安装命令:
composer require samody/laravel-smart-postman-generator
包简介
A smart Laravel-to-Postman collection generator focused on clean structure, smart naming, request body generation, and documentation-ready API exports.
关键字:
README 文档
README
A smarter Laravel-to-Postman exporter focused on generating clean, organized, and documentation-ready Postman collections with minimal manual cleanup.
Built as an enhanced fork of the original:
- Original Package:
andreaselia/laravel-api-to-postman - Original Author: Andreas Elia
This project expands the original idea into a more production-ready API documentation generator for modern Laravel applications.
Why Use This?
The common problems with generated Postman collections:
- Endpoints export with raw route paths as names
- Collections become difficult to navigate as APIs grow
- JSON bodies are flat and not representative of actual payloads
- Teams spend time manually renaming requests and organizing folders
- Large APIs require exporting everything repeatedly
This package solves those issues by generating:
- cleaner request names
- grouped request folders
- smarter JSON payloads
- scalable exports
- documentation-ready collections
Installation
composer require samody/laravel-smart-postman-generator
Publish Configuration
php artisan vendor:publish --tag=postman-config
Quick Start
Export entire API:
php artisan export:postman
Export only a specific API section:
php artisan export:postman --path=api/user
Export with JSON request bodies:
php artisan export:postman --body-mode=json
Export with bearer authentication:
php artisan export:postman --bearer="your-token"
Features
Core Export Features
- ✅ Automatic Laravel route discovery
- ✅ Postman Collection v2.1 export
- ✅ Bearer authentication support
- ✅ Basic authentication support
- ✅ Configurable headers
- ✅ Structured route export
- ✅ CRUD folder generation
- ✅ Docblock descriptions support
Smart Export Features
Route Path Filtering
Export only a section of your API instead of regenerating the entire collection.
php artisan export:postman --path=api/admin
Useful for:
- modular APIs
- large projects
- incremental documentation updates
- team-based API exports
JSON Body Support
Export request bodies as:
jsonform-dataurlencoded
Example:
'body_format' => 'json',
Body Mode Detection
Control how request bodies are generated.
'body_mode' => 'auto',
Supported modes:
| Mode | Description |
|---|---|
| formdata | Always generate form-data |
| json | Always generate JSON |
| auto | Automatically detect best body type |
FormRequest Validation Export
Automatically parse Laravel FormRequest validation rules and export them into Postman request bodies.
Supports:
- validation descriptions
- required field detection
- nullable fields
- arrays
- nested request fields
Smart Naming System (Planned)
Automatically convert technical route paths into readable Postman request names.
Example:
| Route | Method | Generated Name |
|---|---|---|
| api/user/profile | GET | Get User Profile |
| api/user/logout | POST | Request User Logout |
| api/user/orders/{id}/cancel | POST | Cancel User Order |
This removes the need for manually renaming hundreds of requests after export.
Automatic Folder Grouping (Planned)
Automatically organize requests into folders.
Group By Controller
UserController
├── Get User Profile
├── Update User Profile
└── Logout User
Group By Path
User
├── Profile
├── Orders
└── Notifications
Config example:
'group_by' => 'controller',
Supported options:
'controller'
'path'
'none'
Structured JSON Generation (Planned)
Generate real nested JSON payloads from FormRequest validation rules.
Current Flat Output
{
"items.*.product_id": "",
"items.*.quantity": ""
}
Planned Structured Output
{
"items": [
{
"product_id": 1,
"quantity": 1
}
]
}
Example Value Generation (Planned)
Automatically generate intelligent example values.
Example:
{
"email": "john@example.com",
"name": "John Doe",
"quantity": 1,
"is_active": true
}
Potential support:
- Faker integration
- enum value detection
- date examples
- UUID generation
- file placeholders
Configuration
Configuration file:
config/api-postman.php
Example Configuration
return [ 'base_url' => env('APP_URL'), 'structured' => true, 'crud_folders' => true, 'body_mode' => 'auto', 'body_format' => 'json', 'enable_formdata' => true, 'smart_naming' => true, 'group_by' => 'controller', ];
Usage
Export Entire API
php artisan export:postman
Export Specific API Section
php artisan export:postman --path=api/user
Export Using JSON Bodies
php artisan export:postman --body-mode=json
Export With Bearer Token
php artisan export:postman --bearer="your-token"
Export With Basic Auth
php artisan export:postman --basic="username:password"
Output Location
Generated collections are stored in:
storage/app/postman
Example Generated Improvements
Before
api/user/orders/{id}/cancel
After
Cancel User Order
Before
{
"items.*.product_id": ""
}
After
{
"items": [
{
"product_id": 1
}
]
}
Roadmap
Phase 1
- JSON body support
- Body mode support
- Route path filtering
Phase 2
- Smart request naming
- Automatic folder grouping
- Nested path grouping
Phase 3
- Structured JSON generation
- Example value generation
- Faker integration
Phase 4
- Response example generation
- OpenAPI support
- Environment export support
- Swagger compatibility
Testing
composer test
Real-World Benefits
Development
✅ Faster API testing
✅ Cleaner Postman collections
✅ Less manual cleanup
✅ Better onboarding for teams
✅ Easier frontend/backend collaboration
Documentation
✅ Documentation-ready exports
✅ Human-readable request names
✅ Organized request grouping
✅ Better payload representation
Team Collaboration
✅ Consistent Postman structures
✅ Easier API navigation
✅ Faster endpoint discovery
✅ Cleaner API handoffs
Contributing
Contributions are welcome.
You can:
- open issues
- suggest improvements
- submit pull requests
Credits
Original Package
Andreas Elia
andreaselia/laravel-api-to-postman
Smart Fork & Enhancements
Maintained as an enhanced developer-experience focused fork.
License
MIT
samody/laravel-smart-postman-generator 适用场景与选型建议
samody/laravel-smart-postman-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 232 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 05 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「documentation」 「api」 「laravel」 「collection」 「swagger」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 samody/laravel-smart-postman-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 samody/laravel-smart-postman-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 samody/laravel-smart-postman-generator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
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
RESTful API server for structured and self-documenting resources over JSON, XML, ...
统计信息
- 总下载量: 232
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 52
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-07