PHPackages                             lpmatrix/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. lpmatrix/postman-generator

ActiveLibrary[API Development](/categories/api)

lpmatrix/postman-generator
==========================

Laravel package that automatically generates a Postman collection from Laravel routes

10PHP

Since Mar 4Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

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

[](#laravel-postman-generator)

A Laravel package that automatically generates a Postman collection from your Laravel routes, including support for route groups, authentication settings, and customization options.

Features
--------

[](#features)

- Automatic generation of Postman Collection v2.1 from Laravel routes
- Support for route grouping (by prefix, controller, or middleware)
- Intelligent handling of route parameters and request bodies
- Support for FormRequest validation rules to generate example requests
- Authentication configuration (Bearer token, Basic auth)
- Environment variables support
- Customizable output with pretty-printing option
- Works with Laravel 10.x and above

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

[](#installation)

You can install the package via composer:

```
composer require lpmatrix/postman-generator
```

The service provider will be automatically registered for Laravel 8+.

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

[](#configuration)

To publish the configuration file:

```
php artisan vendor:publish --provider="LPMatrix\PostmanGenerator\PostmanGeneratorServiceProvider" --tag="config"
```

This will create a `config/postman-generator.php` file where you can customize the behavior of the package.

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

To generate a Postman collection:

```
php artisan postman:generate
```

This will create a `postman-collection.json` file in your project root that you can import into Postman.

### Command Options

[](#command-options)

```
# Specify a custom output path
php artisan postman:generate --output=custom-file.json

# Pretty-print the JSON output
php artisan postman:generate --pretty

# Include environment variables
php artisan postman:generate --include-env
```

Configuration Options
---------------------

[](#configuration-options)

### Collection Settings

[](#collection-settings)

```
// The name of the generated Postman collection
'collection_name' => env('POSTMAN_COLLECTION_NAME', config('app.name') . ' API'),

// Description for the collection
'description' => env('POSTMAN_COLLECTION_DESCRIPTION', 'API Documentation'),

// Base URL for all requests (can use Postman variables)
'base_url' => '{{baseUrl}}',

// Default base URL value
'default_base_url' => env('APP_URL', 'http://localhost') . '/api',
```

### Route Filtering

[](#route-filtering)

```
// Only include API routes (those with uri starting with 'api/')
'api_routes_only' => true,

// Route URI patterns to exclude
'exclude_patterns' => [
    '_debugbar/*',
    'sanctum/*',
    // ...
],

// HTTP methods to exclude
'exclude_methods' => [
    'HEAD',
    'OPTIONS',
],
```

### Route Grouping

[](#route-grouping)

```
// Strategy for grouping routes into folders
// Supported values: 'prefix', 'controller', 'middleware', 'custom'
'grouping_strategy' => 'prefix',

// Custom grouping function - only used when grouping_strategy is 'custom'
'custom_grouping' => function ($route) {
    // Your custom logic here
    return 'Your Group Name';
},
```

### Authentication

[](#authentication)

```
// Authentication type for the collection
// Supported values: 'noauth', 'bearer', 'basic'
'auth' => [
    'type' => 'bearer',
    'token' => 'your-default-token',
],
```

Advanced Usage Examples
-----------------------

[](#advanced-usage-examples)

### Custom Route Grouping

[](#custom-route-grouping)

If you want to implement a custom grouping logic, you can define a closure in your `AppServiceProvider`:

```
use Acme\PostmanGenerator\PostmanGenerator;

public function boot()
{
    config(['postman-generator.grouping_strategy' => 'custom']);
    config(['postman-generator.custom_grouping' => function ($route) {
        // Your custom grouping logic
        $uri = $route->uri();
        $method = $route->methods()[0];

        // Group by HTTP method
        return strtoupper($method);
    }]);
}
```

### Extracting Documentation from Route Annotations

[](#extracting-documentation-from-route-annotations)

This package automatically extracts documentation from PHPDoc comments in your controller methods. For best results, document your API endpoints like this:

```
/**
 * Get a list of all products.
 *
 * This endpoint returns a paginated list of products with basic information.
 *
 * @return \Illuminate\Http\Response
 */
public function index()
{
    // Your code here
}
```

### Using with FormRequest Validation

[](#using-with-formrequest-validation)

The package automatically detects FormRequest validation rules to generate example request bodies:

```
public function store(StoreProductRequest $request)
{
    // When StoreProductRequest contains validation rules, they will be used
    // to generate an example request body with appropriate data types
}
```

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.

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/429c3bc5d756e9831474db8d96fd9d0446353f5da51542dde67b6895616b61fc?d=identicon)[LPMatrix](/maintainers/LPMatrix)

---

Top Contributors

[![LPMatrix](https://avatars.githubusercontent.com/u/12500715?v=4)](https://github.com/LPMatrix "LPMatrix (3 commits)")

### Embed Badge

![Health badge](/badges/lpmatrix-postman-generator/health.svg)

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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