PHPackages                             puchan/laravel-api-docs - 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. puchan/laravel-api-docs

ActiveLibrary[API Development](/categories/api)

puchan/laravel-api-docs
=======================

Automatic API documentation generator for Laravel applications

1.1.1(6mo ago)0142↓50%MITPHPPHP ^8.1|^8.2|^8.3

Since Oct 16Pushed 6mo agoCompare

[ Source](https://github.com/bunthondev/laravel-api-docs)[ Packagist](https://packagist.org/packages/puchan/laravel-api-docs)[ RSS](/packages/puchan-laravel-api-docs/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Laravel API Docs
================

[](#laravel-api-docs)

[![Latest Version on Packagist](https://camo.githubusercontent.com/adb6843fade718f751a89aab1991dee4e0cd0777c0ab5d0c302996c3717760ab/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70756368616e2f6c61726176656c2d6170692d646f63732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/puchan/laravel-api-docs)[![Total Downloads](https://camo.githubusercontent.com/b7a306f5126e773cb50373ea434e5115bc3868e9a327f0156c85c841f97d283e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70756368616e2f6c61726176656c2d6170692d646f63732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/puchan/laravel-api-docs)[![License](https://camo.githubusercontent.com/ba4f583ee110f85c6ebd285856dc385fd9f7ca3c37a8941bdc80057d5f0f0275/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f70756368616e2f6c61726176656c2d6170692d646f63732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/puchan/laravel-api-docs)

Automatic API documentation generator for Laravel applications. Generate beautiful, interactive API documentation by simply installing the package - **zero configuration required**!

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

[](#-features)

- ✅ **Zero Configuration** - Works immediately after installation
- ✅ **Auto Route Scanning** - Automatically discovers all your API routes
- ✅ **Database Schema Integration** - Shows available fields from database tables with toggle option
- ✅ **Advanced Parameter Detection** - Auto-detects query params from:
    - FormRequests validation rules
    - Method signatures and type hints
    - Controller method body (`$request->has()`, `$request->input()`, etc.)
    - Pagination patterns
- ✅ **Real Data Examples** - Fetches actual data from database for response examples with security sanitization
- ✅ **Smart Response Detection** - Detects custom response patterns:
    - `Resource::collection()` for arrays
    - `new Resource()` for single objects
    - `sendResponse()` custom methods
- ✅ **Laravel Resource Support** - Uses your Resource classes for accurate response examples
- ✅ **Multiple Formats** - HTML, JSON, and OpenAPI/Swagger formats
- ✅ **Compact UI** - Space-efficient table format with optimized spacing and typography
- ✅ **URL Persistence** - Bookmarkable URLs with controller selection state
- ✅ **Pagination Detection** - Automatically identifies paginated endpoints
- ✅ **Highly Configurable** - Customize everything via config file and environment variables

📋 Requirements
--------------

[](#-requirements)

- PHP 8.1 or higher
- Laravel 10.x, 11.x, or 12.x
- PostgreSQL (for database schema reading)

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

[](#-installation)

Install the package via Composer:

```
composer require puchan/laravel-api-docs
```

The package will be auto-discovered by Laravel. **No additional setup required!**

🚀 Quick Start
-------------

[](#-quick-start)

After installation, your API documentation is immediately available at:

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

```

That's it! The package automatically:

- Scans all your API routes
- Reads database schemas (PostgreSQL)
- Detects query parameters from FormRequests AND controller code
- Fetches real data from database for response examples
- Detects Resource::collection() vs single Resources
- Generates response examples with security sanitization
- Creates beautiful, compact documentation with URL persistence

📖 Available Endpoints
---------------------

[](#-available-endpoints)

### 1. HTML Documentation (Interactive UI)

[](#1-html-documentation-interactive-ui)

```
GET /api-docs

```

Beautiful, responsive web interface with:

- Collapsible route sections
- Color-coded HTTP methods
- Compact parameter tables
- Database field information (toggleable)
- Real data examples with security sanitization
- URL persistence for bookmarking
- One-click cURL and Postman export
- Syntax-highlighted JSON examples
- Optimized spacing for maximum content visibility

### 2. JSON Format (Programmatic Access)

[](#2-json-format-programmatic-access)

```
GET /api-docs/json

```

Complete API documentation in JSON format for:

- Custom documentation tools
- CI/CD integration
- API testing tools

### 3. OpenAPI/Swagger Format

[](#3-openapiswagger-format)

```
GET /api-docs/swagger

```

OpenAPI 3.0 compliant format for:

- Swagger UI
- Postman import
- API clients generation

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

[](#️-configuration)

### Publishing Config (Optional)

[](#publishing-config-optional)

While the package works without configuration, you can customize it:

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

This creates `config/api-docs.php`:

```
