nabilaahmed / laravel-postman-exporter
Automatically export and sync Laravel API routes to Postman Collections
Package info
github.com/Nabilaahmed2000/postman-exporter
pkg:composer/nabilaahmed/laravel-postman-exporter
Requires
- php: ^8.2
- illuminate/console: ^10.0|^11.0
- illuminate/http: ^10.0|^11.0
- illuminate/support: ^10.0|^11.0
README
🚀 Automatically sync your Laravel API routes with Postman.
This package iterates through your Laravel routes (api middleware), generates smart JSON request bodies by inspecting your FormRequest classes, and syncs them directly to a Postman Collection using the Postman API.
Features
- Auto-Sync: Creates or updates Postman Collections directly from your CLI.
- Smart Data: Inspects
rules()in yourFormRequestto generate realistic sample JSON data. - Organization: Automatically organizes routes into folders based on route prefixes.
- Environment Ready: Automatically sets up
{{base_url}}as a Postman variable.
Requirements
- PHP 8.2+
- Laravel 10.0 or 11.0
Installation
-
Install via Composer:
composer require nabilaahmed/laravel-postman-exporter
-
Publish Configuration:
php artisan vendor:publish --provider="NabilaAhmed\PostmanExporter\PostmanExporterServiceProvider" -
Configure .env: Add your Postman credentials to your
.envfile:POSTMAN_EXPORTER_API_KEY=your_postman_api_key POSTMAN_EXPORTER_WORKSPACE_ID=your_workspace_id
Usage
Run the command to start the export:
php artisan export:postman
The tool will:
- Ask for a Collection Name.
- Search for an existing collection with that name in your workspace.
- If it exists, it updates it. If not, it creates a new one.
- Export all routes using the
apimiddleware.
Smart Data Generation
If your controller method uses a FormRequest, like this:
public function store(CreateUserRequest $request) { ... }
The tool will look at CreateUserRequest::rules():
return [ 'name' => 'required|string', 'email' => 'required|email|unique:users', ];
And generate this in Postman:
{
"name": "Sample text",
"email": "user@example.com"
}
License
MIT