PHPackages                             myat-kyaw-thu/laravel-api-visibility - 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. myat-kyaw-thu/laravel-api-visibility

ActiveLibrary[API Development](/categories/api)

myat-kyaw-thu/laravel-api-visibility
====================================

Automatic API route documentation and live previewing for Laravel applications

v1.0.0(3mo ago)323MITPHPPHP ^8.0

Since Mar 24Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/myat-kyaw-thu/laravel-api-visibility)[ Packagist](https://packagist.org/packages/myat-kyaw-thu/laravel-api-visibility)[ RSS](/packages/myat-kyaw-thu-laravel-api-visibility/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (6)Versions (2)Used By (0)

Laravel API Visibility
======================

[](#laravel-api-visibility)

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](LICENSE)[![Packagist Version](https://camo.githubusercontent.com/1f70a53ff0f84ec028273dc8cfbad92787d90fdae3a6cb30aca03b26401b2ed0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d7961742d6b7961772d7468752f6c61726176656c2d6170692d7669736962696c697479)](https://packagist.org/packages/myat-kyaw-thu/laravel-api-visibility)[![PHP](https://camo.githubusercontent.com/29e76b25f44fd19ba3a88f85f00b3ac7329ffd604075db0fbbeda87f6c794491/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e302d626c7565)](https://php.net)[![Laravel](https://camo.githubusercontent.com/5cda094da4a3be5a6ced873c25cd03b5dd47118be2fedcb5aa3e3ab82b93a36e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d382d2d31322d726564)](https://laravel.com)

A developer-focused Laravel package that automatically generates API route documentation and provides static endpoint analysis. Designed as a lightweight alternative to Swagger — no annotations, no YAML, no configuration required to get started.

---

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

[](#requirements)

- PHP `^8.0`
- Laravel `^8.0 | ^9.0 | ^10.0 | ^11.0 | ^12.0`

---

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

[](#installation)

```
composer require myat-kyaw-thu/laravel-api-visibility
```

The package auto-registers via Laravel's package discovery. No manual provider registration needed.

### Publish config (optional)

[](#publish-config-optional)

```
php artisan vendor:publish --tag=api-visibility-config
```

### Publish views (optional)

[](#publish-views-optional)

```
php artisan vendor:publish --tag=api-visibility-views
```

---

Routes
------

[](#routes)

The package registers two routes automatically:

URLDescription`/docs`Route documentation overview`/preview/{routeName}`Static endpoint analysis for a specific routeBoth routes are protected by `EnsureDevEnvironment` middleware — they only work when `APP_ENV` is not `production`.

---

/docs page
----------

[](#docs-page)

Displays all collected application routes in a dark compact table UI, grouped by URI prefix.

Features:

- Filter by route, controller, HTTP method, or auth requirement
- Per-row "Details" link to the `/preview` page
- Per-row "Copy URL" button
- **Export JSON** button — downloads a Postman Collection v2.1 file importable into Postman, Insomnia, and other API clients

The export includes:

- App name and base URL from `APP_NAME` / `APP_URL` env
- All routes grouped into Postman folders by URI prefix
- Per-request headers (`Accept`, `Content-Type`, `Authorization` if auth required)
- Request body with example values derived from validation rules
- Path variable definitions for `{param}` segments
- Bearer token variable `{{token}}` pre-wired for auth routes

---

/preview page
-------------

[](#preview-page)

Displays a detailed static analysis of a single endpoint. No HTTP requests are executed.

The sidebar lists all routes. Selecting one shows:

- HTTP method + full URL
- Controller class and method
- Middleware list
- Auth requirement (detected from `auth`, `sanctum`, `jwt` middleware)
- URI parameters (from `{param}` segments)
- Request body fields with validation rule tags (from FormRequest classes)
- Example request payload (JSON, with realistic values based on field names)
- Success response structure (parsed from `response()->json(...)` in the controller)
- Error responses with HTTP status codes
- API Resources detected in the controller method

### How static analysis works

[](#how-static-analysis-works)

The `ResponseStructureExtractor` reads the controller source file via PHP Reflection, extracts the method body, and parses every `response()->json(...)` call using a recursive balanced-bracket parser. No HTTP calls are made. Results are cached per `Class@method` within the request lifecycle.

The `ValidationExtractor` instantiates FormRequest classes via `ReflectionClass::newInstanceWithoutConstructor()` and calls `rules()` to extract validation rules without triggering constructor dependencies.

---

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

[](#configuration)

File: `config/api-visibility.php`

```
return [
    // Master switch
    'enabled' => env('API_VISIBILITY_ENABLED', true),

    // Enable /preview routes
    'enable_preview' => env('API_VISIBILITY_PREVIEW_ENABLED', true),

    // Route prefix (default: no prefix — /docs and /preview at root)
    'route_prefix' => env('API_VISIBILITY_ROUTE_PREFIX', ''),

    // Middleware applied to /docs and /preview routes
    'middleware' => ['web'],

    // Exclude routes that use any of these middleware
    'exclude_middleware' => ['auth.basic'],

    // Exclude these exact URIs (supports {param} wildcards)
    'exclude_uris' => [
        '/',
        'docs',
        'preview',
        'preview/{routeName}',
        '_ignition/health-check',
        'sanctum/csrf-cookie',
    ],

    // Exclude routes whose prefix starts with these strings
    'exclude_prefixes' => ['_debugbar', '_ignition'],

    // Exclude routes from these controller namespaces
    'exclude_namespaces' => [
        'Laravel\Sanctum',
        'Laravel\Fortify',
        'Laravel\Jetstream',
        'Laravel\Horizon',
        'Laravel\Nova',
    ],

    // Include third-party package routes (default: false)
    'include_third_party_routes' => env('API_VISIBILITY_INCLUDE_THIRD_PARTY', false),

    // Always include these namespaces even when third-party filtering is on
    'allowed_third_party_namespaces' => [],

    // Namespaces treated as third-party (excluded when include_third_party_routes is false)
    'third_party_namespaces' => [
        'Filament\\', 'Livewire\\', 'Spatie\\', 'Barryvdh\\',
        'Laravel\\Sanctum\\', 'Laravel\\Fortify\\', 'Laravel\\Telescope\\',
    ],

    // Response formatters
    'formatters' => [
        'json' => \myatKyawThu\LaravelApiVisibility\Core\Formatter\JsonFormatter::class,
    ],
];
```

### Environment variables

[](#environment-variables)

```
API_VISIBILITY_ENABLED=true
API_VISIBILITY_PREVIEW_ENABLED=true
API_VISIBILITY_ROUTE_PREFIX=
API_VISIBILITY_INCLUDE_THIRD_PARTY=false
```

---

Route naming
------------

[](#route-naming)

Routes with an explicit `.name()` are used as-is. Routes without a name get an auto-generated name in the format `{controllername}.{method}` (e.g. `authcontroller.register`). These auto-generated names work with the `/preview/{routeName}` URL.

---

How routes are collected
------------------------

[](#how-routes-are-collected)

`RouteCollector` scans all registered Laravel routes and applies these filters in order:

1. Must have a controller (closure routes are excluded)
2. Not in `exclude_middleware` list
3. Not in `exclude_uris` list
4. Not in `exclude_namespaces` list
5. Not in `exclude_prefixes` list
6. Not a package-internal route (`myatKyawThu\LaravelApiVisibility\*`)
7. Not a Laravel framework route (`Illuminate\*`, `Laravel\*`)
8. Not a third-party route (unless `include_third_party_routes` is true or namespace is in `allowed_third_party_namespaces`)

---

Facade
------

[](#facade)

```
use myatKyawThu\LaravelApiVisibility\Facades\ApiVisibility;

$routes = ApiVisibility::getDocumentation();
```

---

Running tests
-------------

[](#running-tests)

```
composer test

# With HTML coverage report (output in /coverage)
composer test-coverage
```

---

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance82

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

95d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2b9e012fa8e3a1ea0fe8a3bc8e44983090f98a3bc1a0e1760968e3a3b463d0b6?d=identicon)[Myat Kyaw Thu](/maintainers/Myat%20Kyaw%20Thu)

---

Top Contributors

[![myat-kyaw-thu](https://avatars.githubusercontent.com/u/149857208?v=4)](https://github.com/myat-kyaw-thu "myat-kyaw-thu (79 commits)")

---

Tags

composer-packagephp8

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/myat-kyaw-thu-laravel-api-visibility/health.svg)

```
[![Health](https://phpackages.com/badges/myat-kyaw-thu-laravel-api-visibility/health.svg)](https://phpackages.com/packages/myat-kyaw-thu-laravel-api-visibility)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

76518.2M120](/packages/laravel-mcp)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45344.0k1](/packages/pressbooks-pressbooks)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)

PHPackages © 2026

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