PHPackages                             digitalcorehub/laravel-api-docx - 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. digitalcorehub/laravel-api-docx

ActiveLibrary[API Development](/categories/api)

digitalcorehub/laravel-api-docx
===============================

AI-powered automatic API documentation generator for Laravel. Write code. Laravel API Docx writes the docs.

v1.0(6mo ago)11[2 PRs](https://github.com/DigitalCoreHub/laravel-api-docx/pulls)MITPHPPHP ^8.3CI passing

Since Oct 25Pushed 4mo agoCompare

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

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

Laravel API Docx
================

[](#laravel-api-docx)

[![Latest Version on Packagist](https://camo.githubusercontent.com/dcaadd81478c701cb8726baf02b9f9bf62dd55edea32de1ac7943fd548de29f0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6469676974616c636f72656875622f6c61726176656c2d6170692d646f63782e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/digitalcorehub/laravel-api-docx)[![Total Downloads](https://camo.githubusercontent.com/daf906657c42df69c2fd6629ca500f0b680491005b1c9f00a071f3a2785fa294/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6469676974616c636f72656875622f6c61726176656c2d6170692d646f63782e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/digitalcorehub/laravel-api-docx)[![License](https://camo.githubusercontent.com/de4ea0be45c3ed725609a12ab9f92721ac65add216103805a52d67f7dc162f82/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6469676974616c636f72656875622f6c61726176656c2d6170692d646f63782e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/digitalcorehub/laravel-api-docx)[![PHP Version](https://camo.githubusercontent.com/bdb663849df90152c7a8d4db1e08f84249cf3382b4c874ad7be3b07c95b8a91e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6469676974616c636f72656875622f6c61726176656c2d6170692d646f63782e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/digitalcorehub/laravel-api-docx)[![Laravel Version](https://camo.githubusercontent.com/19d5bb0370853f3f5f64da8e47f7b2e14803b7fa5f7c8d04e347ac6849edb9ee/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31322e782d7265642e7376673f7374796c653d666c61742d737175617265)](https://laravel.com)[![Tests](https://camo.githubusercontent.com/5515d3c528977fa40475edb24a64858baa358bbbe409255ee8f9c32c9d8b9c0b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6469676974616c636f72656875622f6c61726176656c2d6170692d646f63782f63692e796d6c3f6c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/digitalcorehub/laravel-api-docx/actions)

**Write code. Laravel API Docx writes the docs.**

*AI-powered automatic API documentation generator for Laravel 12*

[Features](#-features) • [Installation](#-installation) • [Usage](#-usage) • [Examples](#-examples) • [Configuration](#-configuration) • [Contributing](#-contributing)

---

🚀 Features
----------

[](#-features)

### 🤖 **AI-Powered Intelligence**

[](#-ai-powered-intelligence)

- **Smart Documentation**: Automatically generates meaningful descriptions using OpenAI GPT-4
- **Advanced Analysis**: Creates request/response examples, parameter documentation, and error responses
- **Context-Aware**: Understands Laravel patterns and generates relevant documentation
- **Intelligent Caching**: Avoids redundant AI API calls with smart caching

### 📝 **Multiple Output Formats**

[](#-multiple-output-formats)

- **Markdown**: Human-readable documentation perfect for GitHub/GitLab
- **OpenAPI 3.0**: Industry-standard specification for Swagger UI integration
- **Postman Collection**: Ready-to-import API testing collections
- **ReDoc HTML**: Beautiful, interactive documentation pages

### 🔍 **Smart Route Analysis**

[](#-smart-route-analysis)

- **Automatic Discovery**: Scans all API routes (starting with `api/`)
- **Controller Analysis**: Extracts controller and method information
- **DocBlock Integration**: Uses existing docblocks when available
- **Middleware Detection**: Analyzes route middleware and requirements

### ⚡ **Developer Experience**

[](#-developer-experience)

- **Zero Configuration**: Works out of the box with sensible defaults
- **Watch Mode**: Automatically regenerates documentation on file changes
- **Progress Indicators**: Beautiful CLI output with emojis and progress bars
- **Error Handling**: Comprehensive error reporting and recovery

### 🎯 **Laravel 12 Ready**

[](#-laravel-12-ready)

- **Modern PHP**: Built for PHP 8.3+ with latest language features
- **Laravel 12**: Fully compatible with the latest Laravel version
- **Performance**: Optimized for speed and memory efficiency
- **Security**: Follows Laravel security best practices

---

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

[](#-installation)

### Via Composer

[](#via-composer)

```
composer require digitalcorehub/laravel-api-docx
```

The package will automatically register itself with Laravel.

### Publish Configuration

[](#publish-configuration)

```
php artisan vendor:publish --provider="DigitalCoreHub\LaravelApiDocx\LaravelApiDocxServiceProvider" --tag="api-docs-config"
```

### Environment Setup

[](#environment-setup)

Add your OpenAI API key to your `.env` file:

```
OPENAI_API_KEY=your-openai-api-key-here
OPENAI_API_ENDPOINT=https://api.openai.com/v1/chat/completions
```

---

🎯 Usage
-------

[](#-usage)

### Quick Start

[](#quick-start)

Generate documentation for all your API routes:

```
php artisan api:docs
```

This creates:

- 📝 `docs/api.md` - Markdown documentation
- 🔗 `docs/api.json` - OpenAPI 3.0 specification
- 📮 `docs/api.postman.json` - Postman collection
- 🌐 `docs/api.html` - Interactive ReDoc page

### Advanced Usage

[](#advanced-usage)

#### Format Selection

[](#format-selection)

```
# Generate specific formats
php artisan api:docs --format=markdown
php artisan api:docs --format=openapi
php artisan api:docs --format=postman
php artisan api:docs --format=redoc

# Generate all formats (default)
php artisan api:docs --format=all
```

#### AI-Enhanced Documentation

[](#ai-enhanced-documentation)

```
# Generate with advanced AI features
php artisan api:docs --advanced

# Features include:
# - Request/response examples
# - Parameter documentation
# - Error response mapping
# - Smart tagging and grouping
```

#### Watch Mode

[](#watch-mode)

```
# Automatically regenerate on file changes
php artisan api:docs --watch

# Combine with advanced AI
php artisan api:docs --advanced --watch
```

#### Custom Output Paths

[](#custom-output-paths)

```
# Custom output directory
php artisan api:docs --output=/custom/docs/

# Custom file for specific format
php artisan api:docs --format=markdown --output=/path/to/api.md
```

---

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

[](#-how-it-works)

 ```
graph TD
    A[API Routes] --> B[Route Collector]
    B --> C[Controller Analysis]
    C --> D{DocBlock Exists?}
    D -->|Yes| E[Extract DocBlock]
    D -->|No| F[AI Generation]
    E --> G[Documentation Builder]
    F --> H[OpenAI API]
    H --> I[Cache Result]
    I --> G
    G --> J[Format Generators]
    J --> K[Markdown]
    J --> L[OpenAPI]
    J --> M[Postman]
    J --> N[ReDoc HTML]
```

      Loading ### Process Flow

[](#process-flow)

1. **🔍 Route Discovery**: Scans all registered routes and filters API routes
2. **📊 Controller Analysis**: Extracts controller, method, and middleware information
3. **📚 DocBlock Processing**: Checks for existing documentation in controller methods
4. **🤖 AI Enhancement**: Generates descriptions, examples, and parameters using OpenAI
5. **💾 Smart Caching**: Stores AI results to avoid redundant API calls
6. **📝 Documentation Generation**: Creates comprehensive docs in multiple formats

---

📋 Examples
----------

[](#-examples)

### Markdown Output

[](#markdown-output)

```
# API Documentation

Generated automatically by **digitalcorehub/laravel-api-docx**.

## GET|POST /api/users

- **Controller:** `App\Http\Controllers\UserController@index`
- **Name:** `users.index`
- **Middleware:** `auth,throttle:60,1`

Retrieves a paginated list of users with optional filtering and sorting capabilities.

### Parameters
- `page` (query): Page number for pagination
- `per_page` (query): Number of items per page (max 100)
- `search` (query): Search term for filtering users

### Example Request
```json
GET /api/users?page=1&per_page=20&search=john
```

### Example Response

[](#example-response)

```
{
  "data": [
    {
      "id": 1,
      "name": "John Doe",
      "email": "john@example.com",
      "created_at": "2024-01-01T00:00:00Z"
    }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 20,
    "total": 100
  }
}
```

GET /api/users/{user}
---------------------

[](#get-apiusersuser)

- **Controller:** `App\Http\Controllers\UserController@show`
- **Name:** `users.show`
- **Middleware:** `auth`

Displays detailed information about a specific user including profile data and settings.

### Parameters

[](#parameters)

- `user` (path): User ID or username

### Example Response

[](#example-response-1)

```
{
  "id": 1,
  "name": "John Doe",
  "email": "john@example.com",
  "profile": {
    "avatar": "https://example.com/avatar.jpg",
    "bio": "Software Developer"
  },
  "created_at": "2024-01-01T00:00:00Z",
  "updated_at": "2024-01-01T00:00:00Z"
}
```

```

### OpenAPI 3.0 Output

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "API Documentation",
    "description": "Generated automatically by digitalcorehub/laravel-api-docx",
    "version": "1.0.0",
    "contact": {
      "name": "API Support",
      "email": "support@example.com"
    }
  },
  "servers": [
    {
      "url": "https://api.example.com",
      "description": "Production Server"
    },
    {
      "url": "http://localhost:8000",
      "description": "Development Server"
    }
  ],
  "paths": {
    "/users": {
      "get": {
        "summary": "List users",
        "description": "Retrieves a paginated list of users with optional filtering and sorting capabilities.",
        "tags": ["Users"],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page number for pagination",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "description": "Number of items per page",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/User"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "User": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 1
          },
          "name": {
            "type": "string",
            "example": "John Doe"
          },
          "email": {
            "type": "string",
            "format": "email",
            "example": "john@example.com"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  }
}

```

### Postman Collection

[](#postman-collection)

```
{
  "info": {
    "name": "API Documentation",
    "description": "Generated automatically by digitalcorehub/laravel-api-docx",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "version": "1.0.0"
  },
  "item": [
    {
      "name": "Users",
      "description": "User management endpoints",
      "item": [
        {
          "name": "List Users",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json",
                "type": "text"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/users?page=1&per_page=20",
              "host": ["{{base_url}}"],
              "path": ["api", "users"],
              "query": [
                {
                  "key": "page",
                  "value": "1",
                  "description": "Page number"
                },
                {
                  "key": "per_page",
                  "value": "20",
                  "description": "Items per page"
                }
              ]
            },
            "description": "Retrieves a paginated list of users with optional filtering and sorting capabilities."
          }
        }
      ]
    }
  ],
  "variable": [
    {
      "key": "base_url",
      "value": "http://localhost:8000",
      "type": "string"
    }
  ]
}
```

---

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

[](#️-configuration)

### AI Settings

[](#ai-settings)

```
// config/api-docs.php
'ai' => [
    'provider' => 'openai',
    'model' => 'gpt-4o-mini', // or 'gpt-4', 'gpt-3.5-turbo'
    'api_key' => env('OPENAI_API_KEY'),
    'endpoint' => env('OPENAI_API_ENDPOINT', 'https://api.openai.com/v1/chat/completions'),
    'timeout' => 15,
    'max_tokens' => 500,
],
```

### Output Paths

[](#output-paths)

```
'output' => base_path('docs/api.md'),
'openapi_output' => base_path('docs/api.json'),
'postman_output' => base_path('docs/api.postman.json'),
'redoc_output' => base_path('docs/api.html'),
```

### Caching

[](#caching)

```
'cache' => [
    'enabled' => true,
    'store_path' => storage_path('app/laravel-api-docx-cache.php'),
    'ttl' => 3600, // 1 hour
],
```

### Advanced Options

[](#advanced-options)

```
'advanced' => [
    'generate_examples' => true,
    'include_middleware' => true,
    'include_validation_rules' => true,
    'group_by_controller' => true,
    'sort_routes' => 'uri', // 'uri', 'method', 'name'
],
```

---

🧪 Testing
---------

[](#-testing)

### Run Tests

[](#run-tests)

```
# Run all tests
composer test

# Run with coverage
composer test-coverage

# Run specific test suite
./vendor/bin/phpunit --testsuite=Unit
./vendor/bin/phpunit --testsuite=Feature
```

### Code Quality

[](#code-quality)

```
# Check code style
composer check-style

# Fix code style issues
composer fix-style

# Run static analysis
composer analyse

# Security audit
composer audit
```

---

🚀 Performance
-------------

[](#-performance)

### Optimization Tips

[](#optimization-tips)

1. **Enable Caching**: Always enable caching in production
2. **Use Watch Mode**: For development, use `--watch` to avoid manual regeneration
3. **Selective Generation**: Use `--format` to generate only needed formats
4. **AI Optimization**: Use `gpt-4o-mini` for faster AI responses

### Benchmarks

[](#benchmarks)

OperationTimeMemoryRoute Collection~50ms~2MBDocBlock Parsing~100ms~1MBAI Generation (10 routes)~2s~5MBMarkdown Generation~20ms~1MBOpenAPI Generation~30ms~2MB---

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

[](#-contributing)

We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.

### Development Setup

[](#development-setup)

```
# Clone the repository
git clone https://github.com/digitalcorehub/laravel-api-docx.git
cd laravel-api-docx

# Install dependencies
composer install

# Run tests
composer test

# Check code style
composer check-style
```

### Pull Request Process

[](#pull-request-process)

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

---

📊 Roadmap
---------

[](#-roadmap)

### Upcoming Features

[](#upcoming-features)

- **GraphQL Support**: Generate documentation for GraphQL APIs
- **Custom Themes**: Multiple ReDoc themes and customization options
- **API Versioning**: Support for multiple API versions
- **Export Options**: PDF, Word, and other format exports
- **Team Collaboration**: Multi-user documentation editing
- **API Testing**: Built-in API testing capabilities
- **Webhook Integration**: Automatic documentation updates via webhooks

### Version History

[](#version-history)

- **v1.0.0** - Initial release with basic features
- **v1.1.0** - Added Postman and ReDoc support
- **v1.2.0** - Advanced AI features and watch mode
- **v1.3.0** - Performance optimizations and caching improvements

---

🛡️ Security
-----------

[](#️-security)

### Security Policy

[](#security-policy)

We take security seriously. If you discover a security vulnerability, please:

1. **DO NOT** create a public GitHub issue
2. Email us at
3. Include detailed information about the vulnerability
4. We'll respond within 24 hours

### Security Features

[](#security-features)

- **Input Validation**: All inputs are validated and sanitized
- **API Key Protection**: OpenAI API keys are never logged or exposed
- **File Permissions**: Generated files have appropriate permissions
- **Dependency Scanning**: Regular security audits of dependencies

---

📞 Support
---------

[](#-support)

### Getting Help

[](#getting-help)

- 📖 **Documentation**: Check this README and [Wiki](https://github.com/digitalcorehub/laravel-api-docx/wiki)
- 🐛 **Bug Reports**: [GitHub Issues](https://github.com/digitalcorehub/laravel-api-docx/issues)
- 💬 **Discussions**: [GitHub Discussions](https://github.com/digitalcorehub/laravel-api-docx/discussions)
- 📧 **Email**:

### Community

[](#community)

- 🌟 **Star us** on GitHub if you find this project helpful
- 🐦 **Follow us** on Twitter [@DigitalCoreHub](https://twitter.com/DigitalCoreHub)
- 💼 **LinkedIn**: [Digital Core Hub](https://linkedin.com/company/digital-core-hub)

---

📄 License
---------

[](#-license)

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

---

🙏 Acknowledgments
-----------------

[](#-acknowledgments)

- **Laravel Team** for the amazing framework
- **OpenAI** for the powerful AI capabilities
- **ReDoc** for the beautiful documentation UI
- **Postman** for the API testing platform
- **All Contributors** who help make this project better

---

**Made with ❤️ by [Digital Core Hub](https://digitalcorehub.com)**

[Website](https://digitalcorehub.com) • [GitHub](https://github.com/digitalcorehub) • [Twitter](https://twitter.com/DigitalCoreHub) • [LinkedIn](https://linkedin.com/company/digital-core-hub)

*If this project helps you, please give it a ⭐ on GitHub!*

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance70

Regular maintenance activity

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70.4% 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

199d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/32592602?v=4)[Batuhan Haymana](/maintainers/1batu)[@1batu](https://github.com/1batu)

---

Top Contributors

[![1batu](https://avatars.githubusercontent.com/u/32592602?v=4)](https://github.com/1batu "1batu (19 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")

---

Tags

apilaraveldocumentationswaggeropenapiaimarkdownopenai

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/digitalcorehub-laravel-api-docx/health.svg)

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

###  Alternatives

[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k34.0M112](/packages/darkaonline-l5-swagger)

PHPackages © 2026

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