PHPackages                             php-nl/laravel-api-doc - 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. php-nl/laravel-api-doc

ActiveLibrary[API Development](/categories/api)

php-nl/laravel-api-doc
======================

Highly configurable Laravel API documentation generator

v1.0.6(2mo ago)219↓90.9%MITPHPPHP ^8.3.0

Since Mar 27Pushed 2mo agoCompare

[ Source](https://github.com/Php-nl/laravel-api-docs)[ Packagist](https://packagist.org/packages/php-nl/laravel-api-doc)[ RSS](/packages/php-nl-laravel-api-doc/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)Dependencies (8)Versions (8)Used By (0)

Laravel API Doc
===============

[](#laravel-api-doc)

 A highly configurable, beautiful, and interactive API documentation generator for Laravel.

 [![Latest Version on Packagist](https://camo.githubusercontent.com/d7dd217c6e84d6b39a3b0e4d6da43b5d796b7ce5a301918eb512217401d55373/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068702d6e6c2f6c61726176656c2d6170692d646f632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/php-nl/laravel-api-doc) [![PHP from Packagist](https://camo.githubusercontent.com/6fa97e5225b0b3c025c4fefbcfadc6f2f96de2ddc3102b7aa96a41dccc9d7280/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7068702d6e6c2f6c61726176656c2d6170692d646f632e7376673f7374796c653d666c61742d737175617265)](https://php.net) [![Total Downloads](https://camo.githubusercontent.com/6548d23b8097cc3025d101f32c849efb1f52960fc0a4f183c04a9a1e29377e8a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068702d6e6c2f6c61726176656c2d6170692d646f632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/php-nl/laravel-api-doc) [![License](https://camo.githubusercontent.com/e1fa77b152972a290bfd8fcd89968df473e2365f020f03535516e239cfa7091f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7068702d6e6c2f6c61726176656c2d6170692d646f632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/php-nl/laravel-api-doc)

---

**Laravel API Doc** is an elegant, zero-configuration API documentation package designed to give your Laravel projects a beautiful, interactive dashboard out of the box.

Inspired by Laravel's clean DX and the capabilities of packages like Scramble and Scribe, it automatically parses your routes, form requests, models, and JSON resources to generate a live, testable API portal exactly when you need it—without requiring you to write endless generic PHPDoc blocks.

✨ Features
----------

[](#-features)

- **Zero Config Required:** Just install and visit `/docs/api`!
- **Beautiful UI:** A premium, fully responsive 3-column layout built with Livewire and Tailwind CSS.
- **AST Parsing Engine:** Accurately extracts complex validation rules even when your `FormRequest` relies on unresolved route models or unauthenticated users.
- **Smart Model Introspection:** Seamlessly infers parameter types via Eloquent Model casts and database schema.
- **Automatic JSON Resources:** Safely extracts `JsonResource` and `ResourceCollection` schemas, including **automatic Laravel Pagination wrapping** (detects `.paginate()` and adds `links` and `meta` schemas).
- **Interactive "Try It Out" Panel:** Test any endpoint securely from your browser.
- **Advanced Route Filtering:** Exclude routes via URL patterns, route names, middleware, or directly via PHP Attributes.
- **Code Snippets:** Real-time multi-language snippets (cURL, JavaScript, PHP, Python) for your endpoints.
- **OpenAPI Export:** Export your exact API schema compliant with the OpenAPI 3.1.0 specification.
- **Custom Markdown Pages:** Render extra `.md` documentation files directly in the frontend sidebar.

---

📦 Installation
--------------

[](#-installation)

Requires **PHP 8.3+** and **Laravel 11+**.

You can install the package via Composer:

```
composer require php-nl/laravel-api-doc
```

Next, publish the configuration file and assets using:

```
php artisan vendor:publish --tag="laravel-api-doc-config"
php artisan vendor:publish --tag="laravel-api-doc-assets"
```

🚀 Usage
-------

[](#-usage)

Once installed, simply navigate to the predefined documentation route in your browser:

```
http://your-app.test/docs/api

```

### Defining Endpoints

[](#defining-endpoints)

The package leverages Laravel's native routing metadata. Standard PHPDoc blocks, `FormRequest` validations, and parameter `Model` bindings are **automatically extracted** to document your API.

If your controller method returns a `JsonResource` or invokes a `FormRequest`, the package uses **AST Parsing** and **Reflection** to read the structure of your application without actually executing destructive code.

### Customizing Endpoints via Attributes

[](#customizing-endpoints-via-attributes)

Sometimes, you want to explicitly document query parameters or body payloads that aren't tied to a `FormRequest`, or you want to group your routes logically. Laravel API Doc provides custom PHP attributes for the ultimate developer experience (DX).

#### Grouping &amp; Naming

[](#grouping--naming)

Organize your routes in the sidebar using the `#[ApiDoc]` attribute:

```
use PhpNl\LaravelApiDoc\Attributes\ApiDoc;

#[ApiDoc(group: 'Product Management', name: 'Update Product', description: 'Modify an existing product.')]
public function update(Request $request, Product $product)
{
    // ...
}
```

#### Manual Parameters

[](#manual-parameters)

If you pull data directly from the Request (e.g., `request('status')`) instead of using a FormRequest, you can document it seamlessly using parameter attributes:

```
use PhpNl\LaravelApiDoc\Attributes\QueryParam;
use PhpNl\LaravelApiDoc\Attributes\BodyParam;

#[QueryParam('sort', type: 'string', description: 'Field to sort by', enumValues: ['asc', 'desc'])]
#[BodyParam('notify_user', type: 'boolean', required: false, description: 'Send an email notification')]
public function index()
{
    // ...
}
```

#### Unauthenticated Routes

[](#unauthenticated-routes)

By default, the UI assumes your endpoints are secure (requiring Bearer tokens if `auth` middleware is detected). To mark a route as public (like login or register), use the `#[Unauthenticated]` attribute:

```
use PhpNl\LaravelApiDoc\Attributes\Unauthenticated;

#[Unauthenticated]
public function login(Request $request)
{
    // ...
}
```

---

🚫 Excluding Routes
------------------

[](#-excluding-routes)

You might not want your internal or horizon routes showing up in the documentation. Laravel API Doc provides **4 elegant ways** to filter out routes.

### 1. Via Configuration Patterns (URL, Name, Middleware)

[](#1-via-configuration-patterns-url-name-middleware)

Open your `config/laravel-api-doc.php` and define exclusion rules:

```
'routes' => [
    'include' => ['api/*'],

    // Exclude by URL wildcards
    'exclude' => [
        'api/internal/*',
        'api/webhooks/*',
    ],

    // Exclude by Route Name
    'exclude_names' => [
        'admin.*',
        'horizon.*',
    ],

    // Exclude by assigned Middleware
    'exclude_middleware' => [
        'auth:admin',
    ],
],
```

### 2. Via PHP Attributes

[](#2-via-php-attributes)

For the ultimate localized DX, you can ignore a specific Controller or Method directly in the code:

```
use PhpNl\LaravelApiDoc\Attributes\ExcludeFromDocs;

#[ExcludeFromDocs]
class SecretController extends Controller
{
    // ...
}
```

---

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

[](#️-configuration)

You can fully customize the behavior and look of your documentation by modifying `config/laravel-api-doc.php`.

```
return [
    'ui' => [
        'title' => 'My API Documentation',
        'theme' => [
            'primary_color' => '#3b82f6', // Customize your brand color!
            'background_color' => '#f8fafc',
            'sidebar_width' => '300px',
        ],
        'docs_path' => resource_path('docs/api'), // Where your custom .md files live
    ],
    // ...
];
```

### Global Authentication

[](#global-authentication)

Use the **Security &amp; Authentication** panel (found on the dashboard's welcome screen) to securely define your tokens locally. These tokens are placed in your browser's local storage and injected directly into the "Try It Out" playground.

### Custom Markdown Pages

[](#custom-markdown-pages)

You can write standard `.md` Markdown files (e.g., `Getting-Started.md`, `Authentication.md`) and place them in the `resources/docs/api` directory (configurable via `docs_path`). They will be parsed dynamically and explicitly shown in your API sidebar navigation.

---

🛠 Artisan Commands
------------------

[](#-artisan-commands)

For production environments or advanced CI/CD pipelines, Laravel API Doc provides several helpful commands:

#### Caching Documentation

[](#caching-documentation)

Parsing ASTs and reflecting over hundreds of controllers can be heavy. In production, you should cache the schema:

```
php artisan api-doc:cache
```

To clear the cache:

```
php artisan api-doc:clear
```

#### JSON Response Generation

[](#json-response-generation)

Want to show real JSON responses instead of just schema types? Run the response generator command. It will execute safe GET endpoints locally to capture **live representations** of your API returns.

```
php artisan api-doc:generate-responses
```

#### OpenAPI Export

[](#openapi-export)

Export your documentation to an OpenAPI 3.1.0 compatible `openapi.json` file. You can view your schema live at `/docs/api/openapi.json` or generate it via CLI:

```
php artisan api-doc:openapi > openapi.json
```

---

🤝 Contributing
--------------

[](#-contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

📄 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance83

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

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

7

Last Release

88d ago

Major Versions

v0.1.0 → v1.0.12026-03-27

### Community

Maintainers

![](https://www.gravatar.com/avatar/a312a14822b84080fe3fe8b6db51d324499900f08ffbc39eed4b2f0bf33c02b0?d=identicon)[SERFF](/maintainers/SERFF)

---

Top Contributors

[![SERFF](https://avatars.githubusercontent.com/u/588086?v=4)](https://github.com/SERFF "SERFF (19 commits)")

---

Tags

apilaraveldocumentationopenapigeneratedocsphp-nl

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/php-nl-laravel-api-doc/health.svg)

```
[![Health](https://phpackages.com/badges/php-nl-laravel-api-doc/health.svg)](https://phpackages.com/packages/php-nl-laravel-api-doc)
```

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k9.9M89](/packages/dedoc-scramble)[andreaselia/laravel-api-to-postman

Generate a Postman collection automatically from your Laravel API

1.0k625.4k4](/packages/andreaselia-laravel-api-to-postman)[binarytorch/larecipe

Generate gorgeous recipes for your Laravel applications using MarkDown

2.5k2.8M17](/packages/binarytorch-larecipe)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

721160.4k12](/packages/tallstackui-tallstackui)[psalm/plugin-laravel

Psalm plugin for Laravel

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

A laravel facade to interact with Telegram Bots

815320.5k3](/packages/defstudio-telegraph)

PHPackages © 2026

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