evrenonur/api-lens
Composer 安装命令:
composer require evrenonur/api-lens
包简介
Auto-generated, interactive API documentation for Laravel with a modern Vue 3 UI. Zero config, real-time testing, code snippets, OpenAPI export.
README 文档
README
Auto-generated, interactive API documentation for Laravel.
Zero config. Real-time testing. Modern Vue 3 UI. OpenAPI export.
Features
- Zero Configuration — Drop in, visit
/api-lens, done - Auto Route Scanning — Discovers all API routes, controllers, validation rules
- Smart Rule Extraction — Parses
FormRequest, inline$request->validate(), and controller rules - Response Schema Detection — Analyzes
JsonResource/ResourceCollectionclasses automatically - Path Parameter Analysis — Detects route model binding types and constraints
- PHPDoc Integration — Reads
@api-lens-group,@api-lens-auth,@deprecatedannotations - Live API Testing — Send requests directly from the browser, see response + SQL queries + memory
- Code Snippets — Auto-generated cURL, JavaScript (fetch/axios), Python, PHP (Guzzle/HTTP) snippets
- Human-Readable Rules — Transforms
required|string|max:255into plain English - Example Generation — Smart request body examples based on field names and rules
- Rate Limit Info — Extracts throttle middleware configuration
- OpenAPI 3.1.0 Export — Full spec export for Swagger UI, Postman, etc.
- Postman Collection Export — Direct Postman v2.1 collection generation
- API Version Diff — Compare endpoints between versions, generate changelogs
- Dark Mode — Beautiful dark/light theme with system preference detection
- Keyboard Shortcuts —
Ctrl+Ksearch, arrow navigation, Enter to select - Debug Metrics — SQL query count/time, memory usage, execution time per request
Screenshots
Requirements
- PHP 8.1+
- Laravel 10, 11, or 12
Installation
composer require evrenonur/api-lens --dev
Publish the config (optional):
php artisan vendor:publish --tag=api-lens-config
Visit your app at:
http://your-app.test/api-lens
That's it!
Configuration
// config/api-lens.php return [ 'enabled' => env('API_LENS_ENABLED', true), 'path' => 'api-lens', 'middleware' => ['web'], 'include_patterns' => ['api/*'], 'exclude_patterns' => [ 'sanctum/*', '_ignition/*', 'telescope/*', 'horizon/*', 'api-lens/*', ], 'auth' => [ 'enabled' => false, 'middleware' => [], ], 'features' => [ 'live_testing' => true, 'code_snippets' => true, 'openapi_export' => true, 'debug_metrics' => true, 'example_generation' => true, ], 'code_snippets' => [ 'languages' => ['curl', 'javascript', 'python', 'php', 'axios', 'fetch', 'guzzle', 'http'], ], 'cache' => [ 'enabled' => false, 'ttl' => 3600, ], ];
PHPDoc Annotations
Add annotations to your controller methods for richer documentation:
/** * @api-lens-group Users */ class UserController extends Controller { /** * List all users. * * Returns a paginated list of users with optional filtering. * * @api-lens-auth bearer * @api-lens-tag admin * @api-lens-response 200 {"data": [{"id": 1, "name": "John"}], "meta": {"total": 50}} */ public function index(Request $request) { // ... } /** * Create a new user. * * @api-lens-response 201 {"data": {"id": 1, "name": "John"}, "message": "User created"} */ public function store(StoreUserRequest $request) { // ... } /** * Delete user. * * @api-lens-deprecated 2025-06-01 Use PATCH /users/{user}/deactivate instead */ public function destroy(User $user) { // ... } }
Available Annotations
| Annotation | Level | Description |
|---|---|---|
@api-lens-group Name |
Class | Group endpoints under a section |
@api-lens-auth bearer|basic|api-key |
Class/Method | Authentication type |
@api-lens-tag name |
Method | Custom tag |
@api-lens-response {code} {json?} |
Method | Response code with optional JSON example |
@api-lens-deprecated {date} {message} |
Method | Mark as deprecated with migration info |
OpenAPI Export
Via Artisan
# Export as OpenAPI 3.1.0 JSON php artisan api-lens:export docs/openapi.json --format=openapi # Export as Postman Collection php artisan api-lens:export docs/postman.json --format=postman # Default export (api.json in project root) php artisan api-lens:export # Overwrite without confirmation php artisan api-lens:export docs/openapi.json --format=openapi --force
Via API
GET /api-lens/export/openapi
GET /api-lens/export/postman
Live Testing
The built-in API tester lets you:
- Set custom headers (Authorization, Content-Type, etc.)
- Edit JSON request body with smart defaults
- See response status, headers, and formatted body
- View debug metrics: SQL queries, memory usage, execution time
Enable the debug middleware in your config to capture metrics:
'features' => [ 'debug_metrics' => true, ],
Building the Frontend
The Vue 3 frontend is pre-built. To develop or customize:
cd ui npm install npm run dev # Development with HMR npm run build # Production build
Built assets are served from the package automatically.
Security
API Lens is intended for development environments only. To protect in production:
// config/api-lens.php 'enabled' => env('API_LENS_ENABLED', false), // Or add auth middleware 'auth' => [ 'enabled' => true, 'middleware' => ['auth:sanctum', 'can:view-api-docs'], ],
License
MIT License. See LICENSE for details.
evrenonur/api-lens 适用场景与选型建议
evrenonur/api-lens 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 346 次下载、GitHub Stars 达 6, 最近一次更新时间为 2026 年 02 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「documentation」 「api」 「laravel」 「swagger」 「openapi」 「auto-documentation」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 evrenonur/api-lens 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 evrenonur/api-lens 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 evrenonur/api-lens 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Bookdown.io With Bootswatch Styles And Prism Syntax Highlighting
Laravel package that generates RESTful API documentation in Markdown based on PHPDoc.
A PSR-7 compatible library for making CRUD API endpoints
Laravel API documentation generating tool
Alfabank REST API integration
RESTful API server for structured and self-documenting resources over JSON, XML, ...
统计信息
- 总下载量: 346
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 38
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-26



