PHPackages                             mirxan/postman-exporter - 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. mirxan/postman-exporter

ActiveLibrary[API Development](/categories/api)

mirxan/postman-exporter
=======================

Laravel API to Postman Collection exporter with comment-driven customization

v2.0.0(10mo ago)291MITPHPPHP ^8.0 || ^8.1 || ^8.2 || ^8.3 || ^8.4

Since Jul 24Pushed 10mo agoCompare

[ Source](https://github.com/Mirxan/laravel-postman-exporter)[ Packagist](https://packagist.org/packages/mirxan/postman-exporter)[ Docs](https://github.com/mirxan/laravel-postman-exporter)[ RSS](/packages/mirxan-postman-exporter/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (4)Versions (12)Used By (0)

Laravel Postman Exporter 📨
==========================

[](#laravel-postman-exporter-)

A developer-friendly Laravel package that **automatically generates a complete Postman collection** from your routes using PHPDoc-style comments or global configuration. It supports response/parameter detection, headers, bearer authentication, resource structure detection, folder-based grouping — and even Postman environment export!

---

🚀 Installation
--------------

[](#-installation)

### Via Composer:

[](#via-composer)

```
composer require mirxan/postman-exporter
```

If you're installing from a GitHub repo:

🔧 Publish Configuration
-----------------------

[](#-publish-configuration)

Run the following command to publish the configuration file:

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

This will create the config file at:

`config/postman-exporter.php`

⚙️ Configuration Example
------------------------

[](#️-configuration-example)

```
return [

    /*
    |--------------------------------------------------------------------------
    | Storage Disk
    |--------------------------------------------------------------------------
    | The Laravel filesystem disk where the exported collection and environment
    | files will be stored.
    */
    'disk' => 'local',

    /*
    |--------------------------------------------------------------------------
    | Export File Path
    |--------------------------------------------------------------------------
    | The path format where the Postman collection will be saved.
    | You can use {timestamp} and {app} placeholders.
    */
    'path' => 'postman/{app}-collection.json',

    /*
    |--------------------------------------------------------------------------
    | Postman Collection Name
    |--------------------------------------------------------------------------
    */
    'collection_name' => env('APP_NAME', 'Laravel') . now()->toString() . ' API',

    /*
    |--------------------------------------------------------------------------
    | Postman Collection Schema
    |--------------------------------------------------------------------------
    */
    'collection_schema' => 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json',

    /*
    |--------------------------------------------------------------------------
    | Postman Collection ID
    | This value is set automatically.
    |--------------------------------------------------------------------------
    */
    'postman_collection_id' => '',

    /*
    |--------------------------------------------------------------------------
    | Postman Environment ID
    | This value is set automatically.
    |--------------------------------------------------------------------------
    */
    'postman_envirenment_id' => '',

    /*
    |--------------------------------------------------------------------------
    | Postman Workspace ID
    |--------------------------------------------------------------------------
    */
    'postman_workspace_id' => '',

    /*
    |--------------------------------------------------------------------------
    | Postman API Key
    |--------------------------------------------------------------------------
    */
    'postman_api_key' => '',

    /*
    |--------------------------------------------------------------------------
    | Base URL Key
    |--------------------------------------------------------------------------
    | This key will be used in Postman as an environment variable.
    | It will be used like: {{base_url}}/api/...
    */
    'base_url_key' => 'base_url',

    /*
    |--------------------------------------------------------------------------
    | Default Request Parameters
    |--------------------------------------------------------------------------
    | These values will be used for generating form-data parameters
    | in POST, PUT, or PATCH requests.
    */
    'params_value' => [],

    /*
    |--------------------------------------------------------------------------
    | Default Content Type
    |--------------------------------------------------------------------------
    | Options: form-data, urlencoded, multipart, json, raw = json
    */
    'content_type' => 'json',

    /*
    |--------------------------------------------------------------------------
    | Middleware Filtering
    |--------------------------------------------------------------------------
    | Only include routes that have at least one of the following middleware.
    | Leave this empty to include all routes without filtering.
    */
    'included_middlewares' => [
        'api', // Example: 'auth', 'verified', 'throttle:api'
    ],

    /*
    |--------------------------------------------------------------------------
    | Environment File Configuration
    |--------------------------------------------------------------------------
    | This section defines how the Postman environment file will be structured.
    */
    'environment' => [
        'name' => env('APP_ENV', 'local') . 'env',
        'file_name' => 'environment.json',
        'variables' => [
            [
                'key' => 'base_url',
                'value' => env('APP_URL', 'http://localhost'),
                'enabled' => true,
            ],
            [
                'key' => 'token',
                'value' => '',
                'enabled' => true,
            ],
            [
                'key' => 'api_key',
                'value' => 'something',
                'enabled' => true,
            ]
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Folder Structure Configuration
    |--------------------------------------------------------------------------
    | Define folders in your Postman collection and apply global settings.
    | `isGlobal` means the settings apply to every request in this folder.
    */
    'folders' => [

        // Folder keys should correspond to the starting segment of your route prefixes

        // Example for 'api' prefix: folder with global headers and test scripts
        'api' => [
            'level' => 2,
            'isGlobal' => true,
            'headers' => [
                'Accept' => 'application/json',
                'Authorization' => 'Bearer {{token}}',
            ],
            'auth' => [
                'type' => 'bearer',
                'bearer' => [
                    [
                        'key' => 'token',
                        'value' => '{{token}}',
                    ],
                ],
            ],
            'prerequest' => "console.log('Sending request to API endpoint...');",
            'test' => "pm.test('Status is 200', function () {\n    pm.response.to.have.status(200);\n});",
        ],

        // For all prefixes not present in folders, use these settings
        'default' => [
            'level' => 2,
            'isGlobal' => true,
            'headers' => [
                'Accept' => 'application/json',
            ],
            'auth' => [
                'type' => 'bearer',
                'bearer' => [
                    [
                        'key' => 'token',
                        'value' => '{{token}}',
                    ],
                ],
            ],
            'prerequest' => "console.log('Default folder prerequest script');",
            'test' => "pm.test('Default status is 200', function () {\n    pm.response.to.have.status(200);\n});",
        ],
    ],
];
```

📤 Exporting Postman Collection
------------------------------

[](#-exporting-postman-collection)

Run the export command:

```
php artisan export:postman
```

#### It will generate the collection file in:

[](#it-will-generate-the-collection-file-in)

storage/app/postman/
--------------------

[](#storageapppostman)

You can import the `.json` file into Postman to test your Laravel API endpoints.

🔄 Optional: Sync with Postman API
---------------------------------

[](#-optional-sync-with-postman-api)

If you want to automatically sync your collection and environment with Postman (via their API), run the command with the --sync option:

```
php artisan export:postman --sync
```

This will:

✅ Upload or update your collection on your Postman account ✅ Upload or update your environment file

🌍 Exporting Postman Environment This package also exports a ready-to-use Postman environment file:

```
storage/app/postman/laravel_environment.json
```

This allows you to easily manage API variables like `APP_URL`, `TOKEN`, etc., within Postman.

✏️ DocBlock Comments for Customization
--------------------------------------

[](#️-docblock-comments-for-customization)

#### Add PHPDoc-style annotations to your controller methods:

[](#add-phpdoc-style-annotations-to-your-controller-methods)

```
/**
 * @no-auth If this is set, the request will not require authentication.
 * @description Login endpoint for users
 * @header Authorization: Bearer {{TOKEN}}
 * @response 200 - Successful login
 * @response 422 - Validation error
 */
```

`These annotations will be parsed and added to your Postman request definition.`

📦 Response Auto-Detection
-------------------------

[](#-response-auto-detection)

Automatically detects JsonResource and ResourceCollection responses:
--------------------------------------------------------------------

[](#automatically-detects-jsonresource-and-resourcecollection-responses)

return new UserResource($user); // → type: object

return UserResource::collection($users); // → type: array\[object\]

This removes the need for manually defining response schemas.

📁 Output Example
----------------

[](#-output-example)

`storage/app/postman/1721753093_myapp_collection.json`

`storage/app/postman/laravel_environment.json`

You can import both the collection and environment JSON files into Postman.

✅ Features ✅ Laravel 9.x to 12.x support

✅ PHP 8.0 to 8.4 compatibility

✅ Automatically generates Postman collections

✅ Header and parameter detection from PHPDoc

✅ JsonResource and Collection detection

✅ Environment file generation with custom variables

✅ Folder-based grouping and authentication

✅ Supports content types: form-data, json, x-www-form-urlencoded

🛠 Contributing
--------------

[](#-contributing)

Pull requests are welcome! Please feel free to open issues or suggest features.

📄 License
---------

[](#-license)

MIT License © 2025 Muhammadamin Nematov ()

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance54

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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 ~3 days

Total

11

Last Release

309d ago

Major Versions

v1.9.0 → v2.0.02025-08-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/8ec0da8767296030eb432d8a51d69b94c2178a27b94a772107d1a3ef345052d9?d=identicon)[Mirxan](/maintainers/Mirxan)

---

Top Contributors

[![Mirxan](https://avatars.githubusercontent.com/u/39430782?v=4)](https://github.com/Mirxan "Mirxan (11 commits)")

---

Tags

jsonapilaravelgeneratorexportercollectionPostman

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/mirxan-postman-exporter/health.svg)

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

###  Alternatives

[andreaselia/laravel-api-to-postman

Generate a Postman collection automatically from your Laravel API

1.0k644.5k4](/packages/andreaselia-laravel-api-to-postman)[wayofdev/laravel-symfony-serializer

📦 Laravel wrapper around Symfony Serializer.

2117.7k](/packages/wayofdev-laravel-symfony-serializer)

PHPackages © 2026

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