PHPackages                             provydon/docs-generate - 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. provydon/docs-generate

ActiveLibrary[API Development](/categories/api)

provydon/docs-generate
======================

Automatic API documentation for your Laravel app — zero annotations, OpenAPI 3.0 JSON &amp; Swagger UI.

v1.2.3(3mo ago)104.8k↓43.5%MITPHPPHP ^8.1

Since Oct 25Pushed 3mo agoCompare

[ Source](https://github.com/provydon/docs-generate)[ Packagist](https://packagist.org/packages/provydon/docs-generate)[ RSS](/packages/provydon-docs-generate/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (8)Dependencies (16)Versions (10)Used By (0)

🚀 Docs Generate
===============

[](#-docs-generate)

**Automatic API documentation for your Laravel app — no annotations or doc blocks needed, OpenAPI 3.0 JSON &amp; Swagger UI.**

[![MIT License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://choosealicense.com/licenses/mit/)[![Laravel](https://camo.githubusercontent.com/7680ea0b93bc267f6b1a45b568eaeef1324bf14c6404a8b8dde520fc5a4ca6aa/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d392d2d31332d7265642e737667)](https://laravel.com)[![PHP](https://camo.githubusercontent.com/7535257ca228724c93658bd52583d4e47a9bab02c356abf6e54c1d575f2151e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c75652e737667)](https://php.net)

*Generate beautiful API documentation automatically from your existing Laravel code*

[☕ Buy me a coffee](https://buymeacoffee.com/provydon)

[![Swagger UI Screenshot](docs/screenshot.png)](docs/screenshot.png)

---

✨ Why Docs Generate?
--------------------

[](#-why-docs-generate)

**Stop writing documentation manually!** This package automatically generates beautiful Swagger/OpenAPI documentation from your existing Laravel code—no annotations, no code pollution, no maintenance headaches.

### 🎯 **Perfect For:**

[](#-perfect-for)

- **Laravel APIs** that need professional documentation
- **Teams** who want docs that stay in sync with code
- **Developers** who hate writing documentation
- **Projects** that need client-ready API docs

---

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

[](#-quick-start)

**Get documented instantly:**

```
# 1. Install
composer require provydon/docs-generate

# 2. Publish config
php artisan vendor:publish --tag=docs-generate

# 3. Generate docs (instant!)
php artisan docs:generate

# 4. View your beautiful docs
# Visit: http://your-app-url/docs
```

**That's it!** 🎉 Your API is now fully documented.

### 🔗 **Use with Any API Client**

[](#-use-with-any-api-client)

The generated JSON is compatible with all major API clients:

```
# Get the raw OpenAPI JSON
curl http://your-app-url/docs.json
```

**Import into your favorite tools:**

- 📮 **Postman** - Import OpenAPI 3.0 JSON
- 🌙 **Insomnia** - Import OpenAPI spec
- 🚀 **Thunder Client** - VS Code extension
- 🔥 **Bruno** - Open-source API client
- 📱 **Any OpenAPI-compatible tool**

**Code changes → run command → docs automatically reflect changes**

### 🔄 **Documentation Stays in Sync**

[](#-documentation-stays-in-sync)

The best part? Your documentation **automatically stays up-to-date** with your code:

1. **Make code changes** → Add new routes, update controllers, modify validation
2. **Run `php artisan docs:generate`** → Regenerates the documentation
3. **Deploy your code** → Documentation file goes with your code
4. **Documentation is always current** → No manual updates needed!

The `docs.json` file lives in your `public/` folder, so it's part of your project and gets deployed with every code update. Your API documentation will always reflect your latest code changes.

### 🧱 Always Auto Update Your Documentation

[](#-always-auto-update-your-documentation)

Add `php artisan docs:generate` to your deployment script or build pipeline so every release ships with freshly generated docs:

```
add php artisan docs:generate to ur deployment script or in ur build pipeline

```

You can even surface the progress logs in your CI/CD output:

```
🚀 Generating API documentation...

Found 81 API routes

✅ API documentation generated successfully!

📄 Output: /app/public/docs.json

🌐 View at: https://fikets.com/docs

```

---

✨ What You Get
--------------

[](#-what-you-get)

BeforeAfter❌ No documentation
❌ Manual maintenance
❌ Outdated docs✅ Beautiful Swagger UI
✅ Auto-generated from code
✅ Always up-to-date

### 🎨 **Beautiful Swagger UI**

[](#-beautiful-swagger-ui)

- Modern, responsive design
- Interactive "Try it out" functionality
- Professional API explorer
- Mobile-friendly interface

### 🔄 **Zero Maintenance**

[](#-zero-maintenance)

- **Auto-detects** your routes, validation, and auth
- **Stays in sync** with your code changes
- **No annotations** to maintain
- **Regenerate** with one command

### 🛡️ **Production Ready**

[](#️-production-ready)

- Configurable authentication
- CORS handling included
- Error handling built-in
- Laravel-native integration

---

🎯 Key Features
--------------

[](#-key-features)

FeatureDescription🚫 **Zero Annotations**No code pollution—works with existing code🔍 **Smart Detection**Auto-detects routes, validation, and auth📝 **Inline Validation**Supports `$request->validate()` calls🎨 **Beautiful UI**Modern Swagger UI with "Try it out"🔒 **Auth Ready**Built-in authentication support⚙️ **Fully Configurable**Customize everything via config🚀 **Laravel Native**Uses Laravel conventions and patterns

---

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

[](#-requirements)

- **PHP** 8.1+ (Laravel **13** requires **PHP 8.3+** on the host app, matching `laravel/framework`)
- **Laravel** 9.0 through 13.x

---

🛠️ Installation
---------------

[](#️-installation)

### Step 1: Install via Composer

[](#step-1-install-via-composer)

```
composer require provydon/docs-generate
```

### Step 2: Publish Configuration

[](#step-2-publish-configuration)

```
php artisan vendor:publish --tag=docs-generate
```

This creates:

- `config/docs-generate.php` - Configuration file
- `resources/views/vendor/docs-generate/` - Swagger UI view

### Step 3: Generate Documentation

[](#step-3-generate-documentation)

```
php artisan docs:generate
```

### Step 4: View Your Documentation

[](#step-4-view-your-documentation)

Navigate to: `http://your-app-url/docs`

---

🎨 Authentication
----------------

[](#-authentication)

### Documentation Access Control

[](#documentation-access-control)

Control who can access your API documentation:

```
# No authentication (default)
DOCS_AUTH_ENABLED=false

# Authenticated users only
DOCS_AUTH_ENABLED=true
DOCS_AUTH_TYPE=authenticated

# Specific emails only
DOCS_AUTH_ENABLED=true
DOCS_AUTH_TYPE=specific_emails
DOCS_AUTH_ALLOWED_EMAILS=admin@example.com,developer@example.com
```

### API Authentication Detection

[](#api-authentication-detection)

The package automatically detects authentication requirements by checking for these middleware:

- `auth`
- `auth:sanctum`
- `auth:api`
- `sanctum`
- Any middleware containing `Authenticate`

---

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

[](#️-configuration)

### Route Configuration

[](#route-configuration)

Customize your documentation routes:

```
# Enable/disable route registration (default: true)
DOCS_ROUTES_ENABLED=true

# Customize documentation path (default: /docs)
DOCS_PATH=/api-docs

# Customize JSON path (default: /docs.json)
DOCS_JSON_PATH=/api-docs.json
```

### API Information

[](#api-information)

Edit `config/docs-generate.php`:

```
'info' => [
    'title' => env('APP_NAME', 'Laravel API'),
    'description' => 'API Documentation automatically generated',
    'version' => '1.0.0',
    'contact' => [
        'name' => 'API Support',
        'email' => 'support@example.com',
    ],
],
```

---

📁 Output File
-------------

[](#-output-file)

The generated API documentation is saved as `public/docs.json` in your Laravel project. This approach offers several benefits:

- **Always Accessible**: File is in the public folder, accessible via web server
- **Stays with Code**: Documentation file is part of your project and version controlled
- **Auto-Updates**: Latest docs automatically follow code updates when you deploy
- **Part of Project**: Included in version control and deployments
- **CDN Ready**: Can be served via CDN for better performance
- **Simple**: No complex storage configuration needed

**Direct Access:**

```
https://your-app.com/docs.json

```

**Via Route (with error handling):**

```
https://your-app.com/docs.json

```

---

🔧 How It Works
--------------

[](#-how-it-works)

### 1. **Route Analysis**

[](#1-route-analysis)

Scans all Laravel routes with the `api/` prefix and extracts:

- HTTP methods (GET, POST, PUT, DELETE, etc.)
- URI patterns and parameters
- Controller and method names
- Applied middleware (for auth detection)

### 2. **Validation Extraction**

[](#2-validation-extraction)

For each route, it inspects the controller method:

- Identifies FormRequest classes in method parameters
- Detects inline `$request->validate()` calls in method body
- Extracts validation rules from both sources
- Converts rules to OpenAPI schema definitions

### 3. **Smart Type Detection**

[](#3-smart-type-detection)

Based on field names and validation rules, it automatically detects:

- `email` fields → format: email
- `password` fields → format: password, minLength: 8
- `phone` fields → format: phone
- `url` fields → format: uri
- `date` fields → format: date
- `uuid` fields → format: uuid
- `image`/`file` fields → format: binary

### 4. **Authentication Detection**

[](#4-authentication-detection)

Automatically adds security requirements if route has:

- `auth` middleware
- `auth:sanctum` middleware
- `auth:api` middleware
- `sanctum` middleware
- Any middleware containing `Authenticate`

---

📚 Examples
----------

[](#-examples)

### Example 1: FormRequest Validation

[](#example-1-formrequest-validation)

**Laravel Code:**

```
Route::post('/api/users', [UserController::class, 'store'])
    ->middleware('auth:sanctum');

class StoreUserRequest extends FormRequest
{
    public function rules()
    {
        return [
            'name' => 'required|string|max:255',
            'email' => 'required|email|unique:users',
            'password' => 'required|string|min:8',
            'phone' => 'nullable|string',
        ];
    }
}
```

**Generated Swagger:**

```
{
  "paths": {
    "/api/users": {
      "post": {
        "tags": ["Users"],
        "summary": "Create a new User",
        "security": [{"sanctum": []}],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name", "email", "password"],
                "properties": {
                  "name": {"type": "string", "maxLength": 255},
                  "email": {"type": "string", "format": "email"},
                  "password": {"type": "string", "format": "password", "minLength": 8},
                  "phone": {"type": "string", "format": "phone"}
                }
              }
            }
          }
        }
      }
    }
  }
}
```

### Example 2: Inline Validation

[](#example-2-inline-validation)

**Laravel Code:**

```
Route::post('/api/otp/verify', [OtpController::class, 'verify']);

class OtpController extends Controller
{
    public function verify(Request $request)
    {
        $validated = $request->validate([
            'user_id' => 'required|integer|exists:users,id',
            'otp' => 'required|string|digits:6',
            'verified' => 'nullable|boolean',
        ]);
    }
}
```

**Generated Swagger:**

```
{
                "properties": {
                  "user_id": {"type": "integer", "description": "Must exist in users"},
                  "otp": {"type": "string", "pattern": "^[0-9]{6}$", "minLength": 6, "maxLength": 6},
                  "verified": {"type": "boolean"}
  }
}
```

---

🚀 Commands
----------

[](#-commands)

### Generate Documentation

[](#generate-documentation)

```
php artisan docs:generate
```

Generates fresh API documentation from your current routes and controllers.

---

🛠️ Troubleshooting
------------------

[](#️-troubleshooting)

### Documentation not showing?

[](#documentation-not-showing)

Make sure you've run:

```
php artisan docs:generate
```

### Routes not appearing?

[](#routes-not-appearing)

Check that routes have the `api/` prefix:

```
'route_filters' => [
    'prefix' => 'api/',
],
```

### 404 on /docs?

[](#404-on-docs)

Clear route cache:

```
php artisan route:clear
php artisan route:cache
```

---

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

[](#-contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

---

📄 License
---------

[](#-license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

☕ Support
---------

[](#-support)

If this package helped you, consider [buying me a coffee](https://buymeacoffee.com/provydon) to support development!

---

**Made with ❤️ by [Provydon](https://github.com/provydon)**

[⭐ Star on GitHub](https://github.com/provydon/docs-generate) • [🐛 Report Bug](https://github.com/provydon/docs-generate/issues) • [💡 Request Feature](https://github.com/provydon/docs-generate/issues)

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance80

Actively maintained with recent releases

Popularity29

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

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 ~18 days

Recently: every ~32 days

Total

9

Last Release

107d ago

### Community

Maintainers

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

---

Top Contributors

[![provydon](https://avatars.githubusercontent.com/u/31216637?v=4)](https://github.com/provydon "provydon (26 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/provydon-docs-generate/health.svg)

```
[![Health](https://phpackages.com/badges/provydon-docs-generate/health.svg)](https://phpackages.com/packages/provydon-docs-generate)
```

###  Alternatives

[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.6k29.9M148](/packages/laravel-cashier)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M132](/packages/laravel-pulse)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)

PHPackages © 2026

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