定制 piovezanfernando/laravel-api-auto-docs 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

piovezanfernando/laravel-api-auto-docs

最新稳定版本:0.0.4

Composer 安装命令:

composer require piovezanfernando/laravel-api-auto-docs

包简介

Automatically generate Laravel API documentation from request rules, controllers and routes

README 文档

README

License MIT PHP 8.4+

The Hassle-Free automatic API documentation generation for Laravel.
A Swagger alternative with modern Vue 3 interface.
Supports Open API 3.0.0

Features

  • ✨ Light and Dark mode
  • 🚀 Automatic rules fetching from injected Request and by regexp
  • 📋 Automatic routes fetching from Laravel Routes
  • 📝 Support for Laravel logs
  • 🗃️ Support for SQL query and query time analysis
  • ⚡ Support for memory consumption
  • 🔐 Support for Authorization Headers
  • 🎯 Support for Eloquent events
  • 🔄 Support for OpenAPI 3.0.0 exports
  • 🎨 Modern Vue 3 interface

Requirements

  • PHP >= 8.3
  • Laravel 11.x | 12.x | 13.x

Installation

You can install the package via composer:

composer require piovezanfernando/laravel-api-auto-docs

Publish the config file:

php artisan vendor:publish --tag="api-auto-docs-config"

Configuration

The configuration file will be published to config/api-auto-docs.php. Here you can configure:

  • Routes to document
  • Middleware to apply
  • UI customizations
  • And more...

Usage

Accessing the Documentation

By default, the documentation is available at:

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

Generating OpenAPI Specification

To generate the OpenAPI specification file:

php artisan api-docs:export

This will create an api.json file in your project's root directory by default. You can specify a different path:

php artisan api-docs:export storage/app/api.json

Adding Descriptions to Controllers

The package automatically reads the summary and description from your controller methods' PHPDoc comments.

class UserController extends Controller
{
    /**
     * Create a new user.
     *
     * This endpoint allows you to create a new user in the system.
     * The user's name, email, and password are required.
     */
    public function store(CreateUserRequest $request)
    {
        // Your code here
    }
}

Request Validation

The package automatically reads Laravel FormRequest validation rules:

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

Configuration Options

Exclude Routes

In config/api-auto-docs.php:

'hide_matching' => [
    '#^api/internal#',
    '#^_debugbar#',
],

Middleware

'middlewares' => [
    'web',
    'auth', // Add if you want authentication
],

UI Customization

'title' => 'My API Documentation',
'default_headers' => [
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
],

Testing Your API

The built-in UI allows you to:

  • 📤 Send requests directly from the browser
  • 📊 View SQL queries and memory usage
  • 📋 See logs and debug information
  • 💾 Export to OpenAPI format

Export Options

OpenAPI 3.0

Access the OpenAPI specification:

http://your-app.test/docs-api/api?openapi=true

Download the JSON representation via:

http://your-app.test/docs-api/api?json=true

Security

If you want to restrict access to the documentation:

// config/api-auto-docs.php
'middlewares' => [
    'web',
    'auth',
    'can:view-api-docs', // Custom gate
],

Credits

This package is based on the excellent work from
Laravel Request Docs by Rakuten Tech.

All credit for the original idea and implementation goes to
Pulkit Kathuria and the Rakuten Tech engineering team.

This fork extends the original project with additional features, UI redesign, and ongoing maintenance, while preserving the MIT license.

Contributing

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

License

The MIT License (MIT). Please see License File for more information.

Support

Colaboradores

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固