andreaselia/laravel-api-to-postman
Generate a Postman collection automatically from your Laravel API routes. Export to storage/app with an artisan command, configurable output, optional FormRequest scaffolding and rules, and support for Bearer tokens or Basic Auth for routes behind auth middleware.
Pros:
FormRequest classes, providing self-documenting API contracts without manual annotation.Cons:
api-postman.php, allowing teams to:
| Risk Area | Severity | Mitigation |
|---|---|---|
| Route Resolution Issues | Medium | Test with nested routes, resource controllers, and custom middleware. |
| Auth Token Leakage | High | Restrict --bearer/--basic flags to CI/CD or local .env usage. |
| FormRequest Parsing Errors | Low | Validate FormRequest classes adhere to Laravel’s validation rules format. |
| Postman Schema Drift | Medium | Monitor Postman’s schema updates; package may lag (last tested: v2.1.0). |
| Performance Overhead | Low | Generation is CLI-based; impact negligible unless run in CI for every commit. |
.env variables for auth instead of CLI flags?FormRequest for validation, as it auto-generates request examples./users, /products) to validate:
- name: Generate Postman Collection
run: php artisan export:postman --bearer="${{ secrets.API_TOKEN }}"
--bearer/--basic flags for environment-specific tokens (e.g., dev/staging/prod).12.18.1).auth:sanctum) and custom middleware.FormRequest classes to use Laravel’s validation rules. Custom rule classes must be PSR-compatible..env variables vs. CI secrets).composer require andreaselia/laravel-api-to-postman
php artisan vendor:publish --provider="AndreasElia\PostmanGenerator\PostmanGeneratorServiceProvider"
config/api-postman.php to:
'group_by_crud' => false).'export_path' => storage_path('app/postman')).php artisan export:postman and validate the output in Postman.--bearer/--basic flags.post-merge).composer update) to patch bugs (e.g., auth token handling).--bearer tokens in CI/CD if using short-lived credentials.Route::group or middleware exclusions in api-postman.php..env.'debug' => env('POSTMAN_DEBUG', false),
How can I help you explore Laravel packages today?