If you’ve ever worked on an API in Laravel, you already know how boring it gets to update your Postman collection every time a route or request changes.
Add a new endpoint, change a FormRequest, or tweak a controller — and suddenly, your documentation is outdated again.

That’s why I really liked testing this package: yasin_tgh/laravel-postman.
It literally generates a full, structured Postman collection straight from your Laravel routes — in one command.
No more manual setup, no more copy-pasting URLs.

What It Does Exactly

The package scans all your Laravel API routes, detects authentication and validation rules, and creates a ready-to-import Postman collection — all organized, clean, and documented.

It even goes further: if you’re using FormRequest, it automatically generates the request body example for each endpoint.
So when you open Postman, you instantly get a working example without typing a single field.

Key Features That Make It Awesome

  • βœ… One-command generation: php artisan postman:generate

  • 🧠 Auto body generation: from your FormRequest validation rules

  • πŸ—‚ Flexible organization: group routes by prefix, controller, or nested folders

  • πŸ” Auth ready: supports Bearer, Basic Auth, or API Key

  • 🎯 Route filters: include or exclude exactly what you want

  • 🌍 Environment variable support: for sensitive tokens or URLs

Basically, it does everything you wish Postman could do automatically.

Installation

Install it as a dev dependency:

composer require --dev yasin_tgh/laravel-postman

Then publish the config file:

php artisan vendor:publish --provider="YasinTgh\LaravelPostman\PostmanServiceProvider" --tag="postman-config"

Now you’re ready to generate your collection:

php artisan postman:generate 

By default, it’ll save the file here:

storage/postman/api_collection.json

Then just open Postman → Import → File, select that JSON, and boom πŸ’₯
Your entire API appears, perfectly grouped and ready to test.

How Routes Are Organized

The package gives you full control over how your API endpoints are grouped in Postman.
Here’s a small example of the structure config:

'structure' => [
    'folders' => [
        'strategy' => 'nested_path', // 'prefix', 'nested_path', or 'controller'
        'max_depth' => 3,
        'mapping' => [
            'admin' => 'Administration'
        ]
    ],
    'naming_format' => '[{method}] {uri}',
    'requests' => [
        'default_body_type' => 'raw',
    ]
]

I personally like using nested_path — it keeps things super clean when you have multiple modules or versioned APIs (like /v1/users, /v1/jobs, etc.).

Route Filtering

You can easily control which routes are included.
This is great if you only want to export API routes and skip admin ones:

'routes' => [
    'prefix' => 'api',

    'include' => [
        'patterns' => ['api/users/*'],
        'middleware' => ['api']
    ],

    'exclude' => [
        'patterns' => ['admin/*']
    ]
]

That way, your Postman collection only contains what matters — no internal endpoints or debug routes.

Authentication Options

One thing I really like: the package automatically sets up your authentication headers in Postman.

You can choose between Bearer Token, Basic Auth, or API Key depending on your setup.

Bearer Example:

'auth' => [
    'enabled' => true,
    'type' => 'bearer',
    'default' => [
        'token' => env('POSTMAN_AUTH_TOKEN')
    ]
]

Basic Example:

'auth' => [
    'enabled' => true,
    'type' => 'basic',
    'default' => [
        'username' => 'api-user',
        'password' => 'secret'
    ]
]

API Key Example:

'auth' => [
    'enabled' => true,
    'type' => 'api_key',
    'location' => 'header',
    'default' => [
        'key_name' => 'X-API-KEY',
        'key_value' => 'your-api-key-123'
    ]
]

And because everything can use .env variables, you don’t expose any credentials in your config.

Output Configuration

You can also customize where files are stored and how they’re named:

'output' => [
    'driver' => 'local',
    'path' => storage_path('postman'),
    'filename' => 'api_collection'
],

Every time you regenerate, it can even append a date to the filename — helpful when keeping multiple versions.

Example of the Output

Here’s a quick look at what the generated JSON looks like:

{
  "info": {
    "name": "My API",
    "description": "API Documentation"
  },
  "variable": [
    {"key": "base_url", "value": "https://api.example.com"},
    {"key": "auth_token", "value": "your-token"}
  ],
  "item": [
    {
      "name": "[GET] users",
      "request": {
        "method": "GET",
        "auth": {
          "type": "bearer",
          "bearer": [{"key": "token", "value": "{{auth_token}}"}]
        }
      }
    }
  ]
}

Clean, readable, and directly importable into Postman.

Why You Should Try It

If you work with APIs daily, this package is a must-have.
It keeps your docs always in sync with your code, saves tons of time, and avoids human error.

For me, it’s now a standard in my Laravel setups — especially when I’m building something modular or when multiple devs are working on the same API.

πŸ‘‰ GitHub: yasintqvi/laravel-postman