PHPackages                             mohamed-ayman/laravel-postman-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. mohamed-ayman/laravel-postman-generator

ActiveLibrary[API Development](/categories/api)

mohamed-ayman/laravel-postman-generator
=======================================

Professional Laravel package to automatically generate Postman collections from your Laravel routes, controllers, validation rules, and middleware

v2.1.0(5mo ago)03MITPHPPHP ^8.2CI passing

Since Dec 9Pushed 5mo agoCompare

[ Source](https://github.com/dev-mohamed-ayman/laravel-postman-generator)[ Packagist](https://packagist.org/packages/mohamed-ayman/laravel-postman-generator)[ Docs](https://github.com/dev-mohamed-ayman/laravel-postman-generator)[ RSS](/packages/mohamed-ayman-laravel-postman-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (7)Versions (5)Used By (0)

Laravel Postman Generator
=========================

[](#laravel-postman-generator)

[![Latest Version](https://camo.githubusercontent.com/96782273fa882468fbfa698b15968406354f3cf5f85f98bceb91c65a79e97462/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f68616d65642d61796d616e2f6c61726176656c2d706f73746d616e2d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mohamed-ayman/laravel-postman-generator)[![Total Downloads](https://camo.githubusercontent.com/b8767420cd7ef4d7a2697c0cf9aa9c10075f4b018dea1c74e11e984b723be3dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f68616d65642d61796d616e2f6c61726176656c2d706f73746d616e2d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mohamed-ayman/laravel-postman-generator)[![License](https://camo.githubusercontent.com/4d2f544b4820fb73cb91ef79cdd74572a3d8797d9de3e27110b0340d3212ec11/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6f68616d65642d61796d616e2f6c61726176656c2d706f73746d616e2d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mohamed-ayman/laravel-postman-generator)[![GitHub Stars](https://camo.githubusercontent.com/0fbb321c172741a5b1cb144cc70402e59c9dfb2f58ead0a5b0e4fb2a434b341e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6465762d6d6f68616d65642d61796d616e2f6c61726176656c2d706f73746d616e2d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://github.com/dev-mohamed-ayman/laravel-postman-generator)[![GitHub Forks](https://camo.githubusercontent.com/842ce42ed3d4d05c96cb481a2994fa98cd4a37c7be3b6e71ee46512c50685ef6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6465762d6d6f68616d65642d61796d616e2f6c61726176656c2d706f73746d616e2d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://github.com/dev-mohamed-ayman/laravel-postman-generator)

A professional Laravel package that automatically generates Postman collections from your Laravel routes, controllers, validation rules, and middleware. This package scans your entire Laravel project and creates a complete Postman collection with all the necessary information.

Features
--------

[](#features)

✨ **Comprehensive Route Scanning**

- Automatically scans all Laravel routes
- Supports web, API, and custom route groups
- Configurable route inclusion/exclusion

🔍 **Deep Controller Analysis**

- Extracts controller methods and parameters
- Identifies Form Request classes
- Analyzes method signatures and dependencies

✅ **Validation Rule Extraction**

- Extracts validation rules from Form Requests
- Finds custom validation in controllers
- Generates example request bodies based on validation rules

🛡️ **Middleware Analysis**

- Detects authentication middleware (Sanctum, Passport, etc.)
- Extracts required headers from middleware
- Identifies CSRF protection and other security middleware

📦 **Postman Collection Generation**

- Generates complete Postman Collection v2.1.0 JSON
- Organizes routes into folders by path structure
- Includes variables for base URL and authentication tokens
- Adds default headers and authentication configuration

🌐 **Postman API Integration**

- Update existing Postman collections via API
- Create new collections programmatically
- Sync your Laravel API documentation automatically

Installation
------------

[](#installation)

### From Packagist (After Publishing)

[](#from-packagist-after-publishing)

Once the package is published on Packagist, you can install it via Composer:

```
composer require mohamed-ayman/laravel-postman-generator
```

### From GitHub (Before Publishing)

[](#from-github-before-publishing)

If the package is not yet on Packagist, add the GitHub repository to your `composer.json`:

```
{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/dev-mohamed-ayman/laravel-postman-generator"
        }
    ],
    "require": {
        "mohamed-ayman/laravel-postman-generator": "^1.0"
    }
}
```

Then run:

```
composer require mohamed-ayman/laravel-postman-generator
```

### Troubleshooting

[](#troubleshooting)

If you encounter security advisories or installation issues, see [INSTALLATION\_TROUBLESHOOTING.md](INSTALLATION_TROUBLESHOOTING.md) for solutions.

The package will automatically register its service provider.

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag=postman-generator-config
```

This will create a `config/postman-generator.php` file where you can configure:

- Base URL for your API
- Collection name and description
- Output path for the generated JSON file
- Routes to include/exclude
- Postman API credentials (for API updates)

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

Generate a Postman collection from your Laravel routes:

```
php artisan postman:generate
```

This will create a Postman collection JSON file at the configured output path (default: `storage/app/postman-collection.json`).

### Advanced Usage

[](#advanced-usage)

#### Custom Output Path

[](#custom-output-path)

```
php artisan postman:generate --output=storage/app/my-api-collection.json
```

#### Custom Collection Name

[](#custom-collection-name)

```
php artisan postman:generate --name="My Awesome API"
```

#### Custom Base URL

[](#custom-base-url)

```
php artisan postman:generate --base-url=https://api.example.com
```

#### Include Specific Routes

[](#include-specific-routes)

```
php artisan postman:generate --include=api --include=web
```

Or include all routes:

```
php artisan postman:generate --include=all
```

#### Exclude Routes

[](#exclude-routes)

```
php artisan postman:generate --exclude=telescope --exclude=horizon
```

#### Update Postman Collection via API

[](#update-postman-collection-via-api)

First, configure your Postman API key and collection ID in the config file or environment:

```
POSTMAN_API_KEY=your-api-key-here
POSTMAN_COLLECTION_ID=your-collection-id-here
POSTMAN_WORKSPACE_ID=your-workspace-id-here
```

Then run:

```
php artisan postman:generate --update-api --collection-id=your-collection-id
```

### Programmatic Usage

[](#programmatic-usage)

You can also use the package programmatically:

```
use MohamedAyman\LaravelPostmanGenerator\PostmanGenerator;

$generator = app(PostmanGenerator::class);

// Generate collection
$collection = $generator->generate([
    'collection_name' => 'My API',
    'base_url' => 'https://api.example.com',
    'include_routes' => ['api'],
]);

// Save to file
$generator->saveToFile($collection, storage_path('app/my-collection.json'));

// Update via API
$generator->updateViaApi($collection, [
    'collection_id' => 'your-collection-id',
]);
```

How It Works
------------

[](#how-it-works)

### Route Scanning

[](#route-scanning)

The package scans all registered Laravel routes and extracts:

- URI patterns
- HTTP methods
- Route names
- Controller classes and methods
- Middleware stack
- Route parameters

### Controller Analysis

[](#controller-analysis)

For each controller method, the package:

- Uses reflection to analyze method signatures
- Identifies Form Request classes
- Extracts method parameters and types
- Reads docblocks for additional information

### Validation Extraction

[](#validation-extraction)

The package extracts validation rules from:

1. **Form Request Classes**: Reads the `rules()` method
2. **Controller Methods**: Parses `$request->validate()` calls
3. **Validator Facade**: Finds `Validator::make()` calls

### Middleware Analysis

[](#middleware-analysis)

The package analyzes middleware to:

- Detect authentication requirements
- Extract required headers (Authorization, CSRF tokens, etc.)
- Identify custom middleware data requirements

### Collection Generation

[](#collection-generation)

The generated Postman collection includes:

- All routes organized by path structure
- Request methods and URLs
- Request bodies with example data based on validation rules
- Required headers from middleware
- Route parameters as variables
- Authentication configuration
- Environment variables for base URL and tokens

Example Generated Collection Structure
--------------------------------------

[](#example-generated-collection-structure)

```
{
  "info": {
    "name": "Laravel API Collection",
    "description": "Auto-generated Postman collection from Laravel routes"
  },
  "item": [
    {
      "name": "Users",
      "item": [
        {
          "name": "Get Users",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/users",
              "host": ["{{base_url}}"],
              "path": ["api", "users"]
            }
          }
        },
        {
          "name": "Create User",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"string\",\n  \"email\": \"example@email.com\",\n  \"password\": \"string\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/users",
              "host": ["{{base_url}}"],
              "path": ["api", "users"]
            }
          }
        }
      ]
    }
  ],
  "variable": [
    {
      "key": "base_url",
      "value": "http://localhost",
      "type": "string"
    },
    {
      "key": "token",
      "value": "",
      "type": "string"
    }
  ]
}
```

Requirements
------------

[](#requirements)

- PHP &gt;= 8.2
- Laravel &gt;= 11.0
- Guzzle HTTP Client (for Postman API integration)

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Author
------

[](#author)

**Mohamed Ayman**

Support
-------

[](#support)

If you encounter any issues or have questions, please open an issue on [GitHub](https://github.com/dev-mohamed-ayman/laravel-postman-generator/issues).

Repository
----------

[](#repository)

[GitHub Repository](https://github.com/dev-mohamed-ayman/laravel-postman-generator)

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance73

Regular maintenance activity

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

154d ago

Major Versions

v1.1.0 → v2.0.02025-12-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c1fdf84755bdbacee6a57aad6bcd7ff4f89f9427712f36788ae9dc2d2ec8010?d=identicon)[dev-mohamed-ayman](/maintainers/dev-mohamed-ayman)

---

Top Contributors

[![dev-mohamed-ayman](https://avatars.githubusercontent.com/u/159604796?v=4)](https://github.com/dev-mohamed-ayman "dev-mohamed-ayman (6 commits)")

---

Tags

middlewareapilaravelvalidationroutesdocumentationcollectionPostman

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mohamed-ayman-laravel-postman-generator/health.svg)

```
[![Health](https://phpackages.com/badges/mohamed-ayman-laravel-postman-generator/health.svg)](https://phpackages.com/packages/mohamed-ayman-laravel-postman-generator)
```

###  Alternatives

[andreaselia/laravel-api-to-postman

Generate a Postman collection automatically from your Laravel API

1.0k586.2k3](/packages/andreaselia-laravel-api-to-postman)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[galahad/laravel-addressing

Laravel package providing addressing functionality

70316.6k](/packages/galahad-laravel-addressing)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
