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.

00PHP

Since Jun 18Pushed yesterdayCompare

[ 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 today

READMEChangelogDependenciesVersions (1)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)

```
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.

---

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.

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

20

—

LowBetter than 13% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

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://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 (4 commits)")

### 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

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[botman/driver-telegram

Telegram driver for BotMan

93452.6k6](/packages/botman-driver-telegram)[200mph/tnt-express-connect

TNT ExpressConnect (API) client

2228.2k](/packages/200mph-tnt-express-connect)

PHPackages © 2026

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