wfgm5k2d/phplightdoc
Composer 安装命令:
composer require wfgm5k2d/phplightdoc
包简介
Creating auto-documentation
关键字:
README 文档
README
This package automatically analyzes Laravel controllers and routes, extracting information about groups, names, middleware, response codes, and generating user-friendly documentation in JSON format.
📦 Installation
composer require wfgm5k2d/php-light-doc
📦 Publish all files
php artisan vendor:publish --provider='Wfgm5k2d\PhpLightDoc\Providers\PhpLightDocServiceProvider'
Configure environment variables
# Your path to the documentation file PATH_TO_FILE_DOCUMENTATION='/your_full_path_to_file/api_documentation.json' # List folders to scan, separated by commas if there are many PATH_TO_DIR_SCAN='app/Domain, app/Http/Controllers' # Exclude folders from scanning, separated by commas if there are many PATH_TO_DIR_EXCLUDE='app/Http/Controllers/Admin, CustomBackupController'
🚀 Usage
After installation, a command to generate documentation will appear in Laravel:
php artisan doc:generate
The documentation will be saved in the file specified in .env and will be available in the browser at the /doc route.
📝 Annotations and attributes
You can additionally annotate controllers and methods for a more accurate API description.
Controller Grouping
Groups help structure the documentation into thematic sections.
Simple grouping
You can give a name to a controller group. All routes of this controller will fall into the specified group.
Via comment:
// group Users final class UserController extends Controller
Or attribute:
#[DocGName('Users')] final class UserController extends Controller
🆕 Advanced grouping (nested groups)
You can also create top-level groups to combine multiple controllers. To do this, you need to pass a second parameter to the DocGName attribute — the name of the main group.
Via attribute:
// This controller will be placed in the "Users API" subgroup within the main "Users" group #[DocGName('Users API', 'Users')] final class UserController extends Controller { // ... } // This controller will be placed in the "Authentication" subgroup within the same main "Users" group #[DocGName('Authentication', 'Users')] final class AuthController extends Controller { // ... }
This allows you to create a more complex and convenient documentation structure.
Route Description
You can set a clear name for the route:
Via comment:
// name Create a compensation request public function createApplication(Request $request): JsonResponse``` **Or attribute:** ```php #[DocRName('Create a compensation request')] public function createApplication(Request $request): JsonResponse
Middleware Requirements
If a method requires authorization or special headers, specify it explicitly.
Via comment:
// middleware-name Authentication required // middleware-value Authorization: Bearer {token} final class SecureController extends Controller
Or attribute:
#[DocMiddleware('Authentication required', 'Authorization: Bearer {token}')] final class SecureController extends Controller
By default, the following set of middleware is checked: auth, throttle, can, requires.
Response Codes
The package searches for response codes in these constructs:
return response()->json() return new JsonResponse([]) return new JsonResponse([], Response::HTTP_...) return new JsonResponse([], 200)
By default, the response code will be 200 if no others are specified.
You can manually specify the available response codes if they are not detected
Via comment:
// response-codes 200 404 500 public function getUserData(Request $request): JsonResponse``` **Or attribute:** ```php #[DocResponseCodes()] public function getUserData(Request $request): JsonResponse
🔄 Generating and viewing documentation
Run the generation command:
php artisan doc:generate
Open /doc in your browser to view.
How to develop the package locally?
- Deploy a Laravel project locally. The last package build was on Laravel 12
laravel new php-light-doc
- Inside the project, create a
packagesfolder
cd php-light-doc mkdir "packages"
- This is your packages directory. Add the
wfgm5k2dnamespace here
mkdir "wfgm5k2d"
- Clone the package code from the repository into it
- In the providers, connect the package provider
Laravel <= 10v.
- In the
config/app.phpfile, add the package provider to theprovidersarray
'providers' => [ ... \Wfgm5k2d\PhpLightDoc\Providers\PhpLightDocServiceProvider::class, ]
Laravel >= 11v.
- In the
bootstrap/providers.phpfile, add the package provider to the array
return [ ... \Wfgm5k2d\PhpLightDoc\Providers\PhpLightDocServiceProvider::class, ]
- In
composer.json, connect the package in the autoload section
{
"autoload": {
"psr-4": {
"App\\": "app/",
"Wfgm5k2d\\PhpLightDoc\\": "packages/wfgm5k2d/php-lite-doc/src",
...
}
}
}
wfgm5k2d/phplightdoc 适用场景与选型建议
wfgm5k2d/phplightdoc 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 04 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「PhpLightDoc」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wfgm5k2d/phplightdoc 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wfgm5k2d/phplightdoc 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wfgm5k2d/phplightdoc 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
Branded, diagnostic error pages (500, 403, 404, 419, 503) for Filament — native Filament UI, dark mode and translations out of the box.
Turn any PDF into a Pingen-ready A4 letter (generated address cover page + A4 normalisation + safe margins) and send it through the Pingen print & mail API. Laravel-first.
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-03