movemoveapp/laravel-postmangen
Laravel package that generates a Postman collection (JSON) from HTTP requests executed during PHPUnit tests. Configure via .env and phpunit.xml, install the PHPUnit extension and middleware to capture requests and export collections automatically.
Architecture fit
The movemoveapp/laravel-postmangen package is a lightweight, test-focused utility designed to capture HTTP requests during PHPUnit execution and generate Postman collections. It integrates seamlessly with Laravel’s HTTP middleware pipeline and PHPUnit extension system, leveraging Laravel’s native request/response lifecycle. The package’s architecture is modular and non-intrusive, relying on middleware injection and PHPUnit extensions without requiring changes to core application logic. Its primary use case—API documentation generation via automated testing—aligns well with CI/CD pipelines, developer onboarding, and API contract management.
Integration feasibility
Illuminate\Http\Request, Illuminate\Http\Response) and PHPUnit. Compatibility with Laravel 8+ and PHP 8.0+ is assumed but should be validated.statusCode()/statusText().Technical risk
PostmangenMiddleware as the first middleware could interfere with request lifecycle hooks (e.g., authentication, CORS) if not tested. Validate middleware order in your stack.@postmangenMustCapture annotation bypasses URI-based deduplication, which could lead to duplicate or noisy collections if misused.route(), statusCode()) could break if custom implementations deviate from Laravel’s conventions.Key questions
app/Http/Kernel.php have middleware that relies on the raw request (e.g., logging, rate limiting) before PostmangenMiddleware? Could this cause conflicts?--parallel)? The v1.1.2 release notes suggest it disables generation for subsets, but this should be explicitly tested.@postmangenMustCapture) overused?Authorization, X-API-Key) in your test requests that should be redacted or excluded from the Postman collection?Stack fit
phpunit.xml extensions)..env).phpunit). Avoid running it in pre-commit hooks due to potential slowness.Migration path
app/Http/Kernel.php to ensure PostmangenMiddleware won’t break existing logic.<extensions> in phpunit.xml.composer require movemoveapp/laravel-postmangen
php artisan vendor:publish --provider="MoveMoveIo\Postmangen\PostmangenServiceProvider"
POSTMANGEN_TMP=postman/ to .env.phpunit.xml with the <extensions> block.PostmangenMiddleware as the first middleware in Kernel.php.null responses).@postmangenMustCapture annotation on a non-standard endpoint (e.g., PATCH /custom-route).Compatibility
Illuminate\Http\Request/Response. Custom implementations may fail silently or throw errors.Sequencing
postman/ and regenerate after major API changes").Maintenance
@postmangenMustCapture can lead to technical debt if not reviewed.route()). Future Laravel updates could break compatibility.Support
Scaling
auth.postman_collection.json).v1.1.2), but parallel PHPUnit runs may still cause race conditions. Test with --parallel.Failure modes
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Tests fail silently | Empty/incomplete collection | Configure PHPUnit to fail explicitly if the package |
How can I help you explore Laravel packages today?