yasin_tgh/laravel-postman
Larablocks Analysis
yasin_tgh/laravel-postman works with Laravel 10 to 13 (latest release v1.6.0, Nov 13, 2026).
Recommendation checks
RecommendedRecommended by Larablocks: meets all 4 checks.
- Works with Laravel 13, the current version
- Released in the last 12 months (Nov 13, 2026)
- 10,107 downloads a month (at least 10,000)
- 331 GitHub stars (at least 100)
State
Actively maintained- Last stable release: Nov 13, 2026.
- 6 releases in the last 12 months.
- First released: May 8, 2025.
- Monthly downloads: 10,107.
- 0 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Nov 29, 2026.
| Install | |
|---|---|
composer require yasin_tgh/laravel-postman |
|
| Latest Version: | v1.6.0 |
| PHP: | ^8.1 |
| Laravel: | 10 – 13 |
| License: | MIT |
| Last Updated: | Nov 13, 2026 |
| Links: | GitHub · Packagist |
Laravel Postman
Turn your Laravel routes into a ready-to-use Postman collection with one command, and keep it in sync.
No annotations and no hand-written JSON. Laravel Postman reads your routes and FormRequests and builds the collection your team actually wants to use: organized folders, realistic request bodies and working auth.
✨ From validation rules to a ready request
Write your validation rules as usual:
class StoreUserRequest extends FormRequest
{
public function rules(): array
{
return [
'email' => 'required|email',
'password' => 'required|string|min:8|confirmed',
'age' => 'required|integer|min:18',
'role' => ['required', Rule::in(['admin', 'editor'])],
'born_at' => 'required|date_format:Y-m-d',
'tags.*' => 'string',
'addresses.*.city' => 'required|string',
];
}
}
…and get a request body in Postman that passes your own validation:
{
"email": "user89@example.com",
"password": "sample_text",
"password_confirmation": "sample_text",
"age": 27,
"role": "admin",
"born_at": "2026-11-13",
"tags": ["sample_text"],
"addresses": [{ "city": "sample_text" }]
}
Enums, in: lists, number ranges, string lengths, date formats, nested fields, wildcards and confirmed are all understood.
🚀 Quick start
composer require --dev yasin_tgh/laravel-postman
php artisan postman:generate
That's it. Import storage/postman/api_collection.json into Postman (File → Import) and start sending requests.
To customize it, publish the config:
php artisan vendor:publish --tag=postman-config
🧰 Features
| ⚡ Zero-effort docs | Every route under your API prefix, with path variables (:user) and a {{base_url}} variable. |
| 🧪 Realistic request bodies | Generated from FormRequest rules, as raw JSON or form-data. |
| 🗂️ Your folder structure | Group requests by URL path, prefix or controller. |
| 🔐 Auth that just works | Bearer, Basic or API key, applied only to protected routes. |
| ☁️ Two-way Postman Cloud sync | Push changes without losing your saved responses, scripts or manual requests. |
| 🎯 Fine-grained filtering | Include or exclude routes by pattern, middleware or controller. |
📖 Guides
Organize your folders
Pick a strategy in structure.folders.strategy. Here's the same API three ways:
nested_path (default) | prefix | controller |
|---|---|---|
|
|
|
'structure' => [
'folders' => [
'strategy' => 'nested_path', // 'nested_path', 'prefix' or 'controller'
'max_depth' => 10, // nested_path only: deeper routes go in the deepest folder
],
'naming_format' => '[{method}] {uri}', // placeholders: {method} {uri} {controller} {action}
],
Choose which routes to document
Only routes under routes.prefix (default api) are included. You can narrow it down further:
'routes' => [
'prefix' => 'api',
'include' => [
'patterns' => ['api/users/*'], // wildcards
'middleware' => ['auth:sanctum'],
'controllers' => [UserController::class],
],
'exclude' => [
'patterns' => ['api/internal/*'],
'middleware' => ['debug'],
'controllers' => [HealthController::class],
],
],
[!TIP] If a route can't be processed (for example, a missing controller method), it's skipped and listed in the command output with the reason. It never breaks the whole collection.
Shape the request bodies
'structure' => [
'requests' => [
'default_body_type' => 'raw', // 'raw' (JSON) or 'formdata' (used for POST)
'default_values' => [ // override generated values by field name
'email' => 'test@example.com',
'password' => 'password',
],
],
],
default_values also fill in path variables. For example, 'user' => 42 sets :user to 42.
Set up authentication
'auth' => [
'enabled' => true,
'type' => 'bearer', // 'bearer', 'basic' or 'api_key'
'location' => 'header', // api_key only: 'header' or 'query'
'default' => [
'token' => env('POSTMAN_AUTH_TOKEN'), // bearer
'username' => env('POSTMAN_AUTH_USER'), // basic
'password' => env('POSTMAN_AUTH_PASSWORD'),
'key_name' => 'X-API-KEY', // api_key
'key_value' => env('POSTMAN_AUTH_API_KEY'),
],
'protected_middleware' => ['auth', 'auth:api', 'auth:sanctum'],
],
Routes behind one of the protected_middleware get your auth. Every other route is set to No Auth, so public endpoints never receive your credentials. The values are stored as collection variables ({{auth_token}}, …), so you change them in one place.
[!WARNING] Make sure
protected_middlewarelists the guards your app uses (e.g.auth:sanctum). Otherwise protected routes are generated with No Auth.
☁️ Sync with Postman Cloud
Keep a shared Postman collection up to date as your API changes, without overwriting the work your team has done in Postman.
1. Add your credentials to .env:
POSTMAN_API_KEY=PMAK-xxxxxxxx # go.postman.co/settings/me/api-keys
POSTMAN_COLLECTION_ID=12345678-xxxx # see "Finding your collection ID" below
POSTMAN_WORKSPACE_ID= # optional
2. Preview, then push:
php artisan postman:generate --dry-run # show what would change, push nothing
php artisan postman:generate --push # merge and push to Postman Cloud
Merging…
New requests: 2
- POST /api/users
- DELETE /api/users/:user
Updated requests (remote responses, scripts and ids kept): 1
- GET /api/users
Remote-only requests kept: 1
- Status page
[dry-run] Merge complete — no changes pushed to Postman Cloud.
[!TIP]
--dry-runand--pushexit with a non-zero code on failure, so you can run them in CI.
What happens on a push
| In Postman | On --push |
|---|---|
| New Laravel routes | ➕ Added to the matching folder |
| Request bodies, headers, URLs of existing routes | 🔄 Updated from your code |
| Saved example responses | ✅ Kept (preserve_responses) |
| Pre-request and test scripts | ✅ Kept (preserve_scripts) |
| Requests and folders you added by hand | ✅ Kept (preserve_manual_items) |
| Descriptions written in Postman | ✅ Kept (overwrite_descriptions: false) |
| Auth set by hand on a public route | ✅ Kept (protected routes use your auth config) |
| Collection variables | ✅ Kept; new ones are added |
| Requests for deleted or renamed routes | ✅ Kept by default · 🗑️ removed with prune_stale_routes: true |
'cloud' => [
'api_key' => env('POSTMAN_API_KEY'),
'collection_id' => env('POSTMAN_COLLECTION_ID'),
'workspace_id' => env('POSTMAN_WORKSPACE_ID'),
'merge' => [
'preserve_responses' => true,
'preserve_scripts' => true,
'preserve_manual_items' => true,
'overwrite_descriptions' => false,
'prune_stale_routes' => false,
],
],
[!WARNING]
prune_stale_routesremoves any remote request whose URL starts with{{base_url}}under your route prefix and has no matching route, including ones you created by hand. Run--dry-runfirst and check the "Stale requests removed" list.
Finding your collection ID
In the Postman app: open the collection → ⋯ → Info → copy the Collection ID.
With the Postman API: list your collections and copy the uid:
curl -s https://api.getpostman.com/collections -H "X-Api-Key: $POSTMAN_API_KEY" \
| php -r 'foreach (json_decode(stream_get_contents(STDIN), true)["collections"] ?? [] as $c) echo "{$c["name"]} => {$c["uid"]}\n";'
⚙️ Configuration reference
All options in config/postman.php
| Option | Default | Description |
|---|---|---|
name |
APP_NAME |
Collection name |
description |
API_DESCRIPTION |
Collection description |
base_url |
APP_URL |
Value of the {{base_url}} variable |
routes.prefix |
api |
Only routes under this prefix are documented |
routes.include.* / routes.exclude.* |
[] |
Filter by patterns, middleware, controllers |
structure.folders.strategy |
nested_path |
nested_path, prefix or controller |
structure.folders.max_depth |
10 |
Folder depth for nested_path |
structure.naming_format |
[{method}] {uri} |
Request names: {method} {uri} {controller} {action} |
structure.requests.default_body_type |
raw |
raw or formdata |
structure.requests.default_values |
[] |
Fixed values per field or path variable |
auth.enabled |
false |
Add auth to protected routes |
auth.type |
bearer |
bearer, basic or api_key |
auth.location |
header |
Where the API key goes: header or query |
auth.protected_middleware |
auth, auth:api, auth:sanctum |
Middleware that marks a route as protected |
headers |
Accept, Content-Type |
Headers on every request (Content-Type only with raw bodies) |
output.driver |
local |
Filesystem driver (POSTMAN_STORAGE_DISK) |
output.path |
storage/postman |
Output directory (POSTMAN_STORAGE_DIR) |
output.filename |
api_collection |
File name; .json is added if missing (POSTMAN_STORAGE_FILE) |
cloud.* |
— | See Sync with Postman Cloud above |
❓ FAQ
A route is missing from my collection
Check that it's under routes.prefix and isn't removed by an include/exclude filter. Routes that can't be processed are listed as Skipped in the command output, with the reason.
A request has an empty body
Bodies are generated from a FormRequest type-hinted in the controller method. Plain Request $request parameters and inline $request->validate() calls have no rules to read.
Auth isn't applied to my protected routes
Make sure auth.enabled is true and that auth.protected_middleware contains the exact middleware your routes use, e.g. auth:sanctum.
🤝 Contributing
Pull requests are welcome! For major changes, please open an issue first.
composer install
composer test
📄 License
MIT. See LICENSE.
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v1.6.0 | ^8.1 | ^10.0| | MIT | |
| v1.5.0 | ^8.1 | ^10.0| | MIT | |
| v1.4.8 | ^8.1 | ^10.0| | MIT | |
| v1.4.7 | ^8.1 | ^10.0| | MIT | |
| v1.4.6 | ^8.1 | ^10.0| | MIT | |
| v1.4.5 | ^8.1 | ^10.0| | MIT | |
| v1.4.3 | ^8.1 | ^10.0| | MIT | |
| v1.4.0 | ^8.1 | ^10.0| | MIT | |
| v1.3.2 | ^8.1 | ^10.0| | MIT | |
| v1.3.1 | ^8.1 | ^10.0| | MIT | |
| v1.3.0 | ^8.1 | ^10.0| | MIT | |
| v1.2.5 | ^8.1 | ^10.0| | MIT | |
| v1.2.4 | ^8.1 | ^10.0| | MIT | |
| v1.2.3 | ^8.1 | ^10.0| | MIT | |
| v1.2.2 | ^8.1 | ^10.0| | ||
| v1.2.1 | ^8.1 | ^10.0| | ||
| v1.2.0 | ^8.1 | ^10.0| | ||
| v1.1.0 | ^8.1 | ^10.0| |
Pre-releases (1)
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v1.0.0-beta | ^8.1 | ^10.0| |