PHPackages                             bhaveshsoni26/laravel-postman-sync - 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. bhaveshsoni26/laravel-postman-sync

ActiveLibrary[API Development](/categories/api)

bhaveshsoni26/laravel-postman-sync
==================================

Automatically scan Laravel API routes and generate a Postman Collection, environment, docs and tests.

v1.0.2(1mo ago)13MITPHPPHP &gt;=8.2

Since Jun 18Pushed 1mo agoCompare

[ Source](https://github.com/Bhaveshsoni26/Laravel-Postman-Sync)[ Packagist](https://packagist.org/packages/bhaveshsoni26/laravel-postman-sync)[ RSS](/packages/bhaveshsoni26-laravel-postman-sync/feed)WikiDiscussions master Synced 2w ago

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

Laravel Postman Sync
====================

[](#laravel-postman-sync)

> Turn your Laravel API routes into a complete, importable **Postman Collection** — docs, examples, tests, environments, and one-command push — with **zero manual annotations**.

 [![PHP 8.2+](https://camo.githubusercontent.com/2795c86d2dea6aba6285347c2adef64310db832ec1d2d634a32e3b51115a5c95/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d373737424234)](#requirements) [![Laravel 10 | 11 | 12](https://camo.githubusercontent.com/a0cfcd4ae10ce58c14aafcab200fa0c44994a20f1da44fa3ae27efbca47abb51/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d3130253230253743253230313125323025374325323031322d464632443230)](#requirements) [![Tests](https://camo.githubusercontent.com/788e726c61182e281d7a7fcb1f863775c2d4a7a7dfa03e1736b37663553ecd4b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d363725323070617373696e672d334642393530)](https://camo.githubusercontent.com/788e726c61182e281d7a7fcb1f863775c2d4a7a7dfa03e1736b37663553ecd4b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d363725323070617373696e672d334642393530) [![PHPStan](https://camo.githubusercontent.com/9172b843d265b7e42aadaa679aa7c19c45afc224d5b6b78d0ae2344042b16230/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c2532306d61782d324542464135)](https://camo.githubusercontent.com/9172b843d265b7e42aadaa679aa7c19c45afc224d5b6b78d0ae2344042b16230/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c2532306d61782d324542464135) [![Code style](https://camo.githubusercontent.com/33e55189a697d8044b6a8e2e4e1c5e725270bd9d0238469564246b6ee51373f3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64652532307374796c652d50696e742d464632443230)](https://camo.githubusercontent.com/33e55189a697d8044b6a8e2e4e1c5e725270bd9d0238469564246b6ee51373f3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64652532307374796c652d50696e742d464632443230) [![License](https://camo.githubusercontent.com/d86b49c0e5112cdefb9b09076360b299a52d10fdfdca46f07747c22b84b3e35a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d334642393530)](https://camo.githubusercontent.com/d86b49c0e5112cdefb9b09076360b299a52d10fdfdca46f07747c22b84b3e35a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d334642393530)

 [**📖 Documentation**](https://postman-sync.bhaveshdev.in) · [Packagist](https://packagist.org/packages/bhaveshsoni26/laravel-postman-sync) · [Issues](https://github.com/Bhaveshsoni26/Laravel-Postman-Sync/issues)

```
php artisan postman:sync
```

That's it. The package scans every API route, reads your controllers and `FormRequest` classes, and writes a Postman Collection v2.1 (with embedded docs and test scripts), per-stage environment files, and an OpenAPI document — then, with `--push`, syncs it straight to your Postman workspace.

> 📖 **Full documentation, guides and examples:** [postman-sync.bhaveshdev.in](https://postman-sync.bhaveshdev.in)

---

Why
---

[](#why)

Keeping a Postman collection in step with a growing API is tedious and always out of date. This package makes the collection a **build artifact**: re-run one command and your routes, request bodies, auth, examples, docs, and tests regenerate deterministically. Add 10 new endpoints and `--push` appends just those — without clobbering the manual edits your team made in Postman.

Features
--------

[](#features)

- 🔎 **Automatic route scanning** — every `GET/POST/PUT/PATCH/DELETE`, `apiResource`, and `resource`; derives version, group, controller, and middleware.
- 🧬 **Reflection-based analysis** — finds each controller's `FormRequest` and reads its `rules()`; no annotations required.
- 🧾 **Typed request bodies + examples** — `required|email|min:8|in:…|confirmed|nullable|file`… mapped to types and realistic example values, including nested/wildcard keys.
- 🔐 **Auth detection** — `auth:` → Bearer `{{guard_token}}`; collection-level auth with per-request overrides; public routes set `noauth`.
- 📦 **Postman Collection v2.1** — folder-grouped, fully **variable-driven** (`{{base_url}}`, `:id` path vars) — no hardcoded hosts or secrets.
- 📚 **Docs in Postman** — endpoint summary, field table, and example responses embedded in each request's **Docs** tab (plus folder/collection descriptions).
- 🧪 **Generated test scripts** — status / response-time / JSON assertions, login-token capture into the environment, and validation/CRUD stubs.
- 🌱 **Environment files** — one per stage (`local`/`staging`/`production`) with secret-typed guard tokens.
- 📜 **OpenAPI 3.0.3** — `openapi.json` generated alongside.
- 🚀 **One-command push** — `--push` uploads to the Postman API with **incremental merge** (append new, regenerate changed, preserve unchanged + manual edits) or `--fresh` full replace.
- 🛟 **Never breaks your build** — closures, missing FormRequests, and bad controllers degrade gracefully with warnings; exits `0`.

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

[](#requirements)

PHP**8.2+**Laravel**10, 11, or 12**Installation
------------

[](#installation)

```
composer require bhaveshsoni26/laravel-postman-sync
```

The service provider auto-registers via package discovery. Publish the config:

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

> Not on Packagist yet? Install from a local path repository — see **[INSTALLATION.md](INSTALLATION.md)** for the one-time `repositories` setup.

Quick start
-----------

[](#quick-start)

```
# Generate collection + environments + openapi.json (into storage/app/postman/)
php artisan postman:sync
```

```
+---------------------+-------+
| Metric              | Value |
+---------------------+-------+
| Routes Found        | 164   |
| Requests Generated  | 164   |
| Warnings            | 0     |
| Files Written       | 5     |
+---------------------+-------+
Synced Successfully

```

Import `storage/app/postman/collection.json` and an environment file into Postman, fill in the token variables, and send.

What it generates
-----------------

[](#what-it-generates)

```
storage/app/postman/
├── collection.json                   # Postman Collection v2.1 (docs + test scripts embedded)
├── openapi.json                      # OpenAPI 3.0.3
├── local.postman_environment.json    # one per configured stage
├── staging.postman_environment.json
└── production.postman_environment.json

```

Command reference
-----------------

[](#command-reference)

CommandResult`postman:sync`collection + environments + openapi (default)`postman:sync --only=collection`only `collection.json``postman:sync --only=environment`only the environment file(s)`postman:sync --only=openapi`only `openapi.json``postman:sync --docs-files`also write standalone Markdown to `/docs/``postman:sync --output=build/postman`custom output directory`postman:sync --push`generate, then **merge** into the Postman collection`postman:sync --push --fresh`full replace of the remote collectionPush to Postman
---------------

[](#push-to-postman)

```
POSTMAN_API_KEY=PMAK-xxxx
POSTMAN_COLLECTION_ID=xxxx   # set to update an existing collection
POSTMAN_WORKSPACE_ID=xxxx    # optional, used when creating
```

```
php artisan postman:sync --push
# Pushed to Postman (merge): added 10, updated 2, unchanged 152, orphaned 0 [12345-abc]
```

Incremental merge appends new routes, regenerates changed ones, and **leaves unchanged requests — including manual edits to their docs/tests — untouched**. Use `--fresh` to overwrite the whole collection.

### Getting your Postman credentials

[](#getting-your-postman-credentials)

You only need the **API key** to push. The **collection ID** and **workspace ID** are optional (see notes below).

#### 1. API key — `POSTMAN_API_KEY` (required)

[](#1-api-key--postman_api_key-required)

1. Sign in to Postman and open **[go.postman.co/settings/me/api-keys](https://go.postman.co/settings/me/api-keys)***(or: click your avatar, top-right → **Settings** → **API keys**).*
2. Click **Generate API Key**, give it a name (e.g. `laravel-postman-sync`), and **Generate**.
3. Copy the key — it starts with `PMAK-` — and put it in `.env`: ```
    POSTMAN_API_KEY=PMAK-xxxxxxxxxxxxxxxxxxxxxxxx
    ```

    > Treat it like a password. You can only see it once; regenerate if you lose it.

#### 2. Collection ID — `POSTMAN_COLLECTION_ID` (optional)

[](#2-collection-id--postman_collection_id-optional)

Leave this **empty the first time** — `--push` creates a new collection and prints its ID:

```
Pushed to Postman (create): added 484, ... [12345678-aaaa-bbbb-cccc-1234567890ab]

```

Copy that ID into `.env` so future pushes **update** the same collection instead of creating duplicates:

```
POSTMAN_COLLECTION_ID=12345678-aaaa-bbbb-cccc-1234567890ab
```

To target a collection that **already exists**, fetch its exact API `uid` (not the short id shown in the app) — list them with your key:

```
curl -s -H "X-Api-Key: $POSTMAN_API_KEY" https://api.getpostman.com/collections | json_pp
```

Use the `uid` value from the response (looks like `12345678-...`).

#### 3. Workspace ID — `POSTMAN_WORKSPACE_ID` (optional)

[](#3-workspace-id--postman_workspace_id-optional)

Only used when **creating** a new collection, to place it in a specific workspace. Omit it to use your default workspace.

- **From the app:** open the workspace, then look at the browser URL: `https://go.postman.co/workspace/My-Team~`**``**`/...` — the ID is the part after the `~`.
- **Via the API:** list your workspaces and copy the `id`: ```
    curl -s -H "X-Api-Key: $POSTMAN_API_KEY" https://api.getpostman.com/workspaces | json_pp
    ```

```
POSTMAN_WORKSPACE_ID=abcdef12-3456-7890-abcd-ef1234567890
```

> After editing `.env`, run `php artisan config:clear` so Laravel picks up the new values, then `php artisan postman:sync --push`.

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

[](#configuration)

Key options in `config/postman-sync.php`:

```
'api_prefix'      => 'api',                 // routes to scan
'output_path'     => storage_path('app/postman'),
'base_url'        => env('APP_URL').'/api', // seeds {{base_url}}
'default_guard'   => 'sanctum',             // collection-level auth
'guard_tokens'    => [],                    // guard => token var override
'environments'    => ['local', 'staging', 'production'],
'generate_tests'  => true,
'capture_login_token' => true,
'postman' => [
    'api_key'       => env('POSTMAN_API_KEY'),
    'collection_id' => env('POSTMAN_COLLECTION_ID'),
    'sync_mode'     => 'merge',             // merge | replace
    'prune_orphans' => false,
],
```

Full configuration reference and a multi-guard (CRM-style) example are in **[INSTALLATION.md](INSTALLATION.md)**.

How it works
------------

[](#how-it-works)

```
RouteScanner ─► RequestAssembler ─► CollectionBuilder ─┐
   (ControllerScanner + Validation/Auth/Example/        ├─► collection.json
    Response extractors)                                 │   environment.json
                                ─► EnvironmentGenerator ─┤   openapi.json
                                ─► MarkdownGenerator ────┤   (+ docs in request descriptions)
                                ─► OpenApiGenerator ─────┤
                                ─► TestScriptBuilder ────┘
                                ─► PostmanSyncService ─► CollectionMerger ─► PostmanApiClient  (--push)

```

A one-directional pipeline of immutable DTOs; each stage is interface-backed and independently tested.

Testing
-------

[](#testing)

```
composer test     # Pest
composer stan     # PHPStan level max
composer lint     # Pint --test
```

All Postman API calls go through Laravel's `Http` facade and are mocked with `Http::fake()` — the test suite needs no real API key or network.

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

[](#contributing)

Issues and PRs welcome. Please run `composer test && composer stan && composer lint` before submitting. New code uses `declare(strict_types=1)` and Sorbet-style full type hints; tests are written in Pest.

License
-------

[](#license)

MIT.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance91

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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

3

Last Release

45d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/88702779?v=4)[Bhaveshsoni26](/maintainers/Bhaveshsoni26)[@Bhaveshsoni26](https://github.com/Bhaveshsoni26)

---

Top Contributors

[![Bhavesh-applocum](https://avatars.githubusercontent.com/u/126673798?v=4)](https://github.com/Bhavesh-applocum "Bhavesh-applocum (7 commits)")

---

Tags

api-documentationartisanautomationdeveloper-toolslaravel-apilaravel-packagelaravel-postmanopen-sourcephppostman-collectionrest-api

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/bhaveshsoni26-laravel-postman-sync/health.svg)

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

###  Alternatives

[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

78727.1M205](/packages/laravel-mcp)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.4M352](/packages/psalm-plugin-laravel)[nuwave/lighthouse

A framework for serving GraphQL from Laravel

3.5k12.2M124](/packages/nuwave-lighthouse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9872.4M142](/packages/roots-acorn)[propaganistas/laravel-disposable-email

Disposable email validator

6023.2M7](/packages/propaganistas-laravel-disposable-email)[forjedio/inertia-table

Backend-driven dynamic tables for Laravel + Inertia.js

272.0k](/packages/forjedio-inertia-table)

PHPackages © 2026

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