承接 evrenonur/api-lens 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

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

Latest Version on Packagist Total Downloads License: MIT PHP Version Laravel Vue.js GitHub Stars

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 / ResourceCollection classes automatically
  • Path Parameter Analysis — Detects route model binding types and constraints
  • PHPDoc Integration — Reads @api-lens-group, @api-lens-auth, @deprecated annotations
  • 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:255 into 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 ShortcutsCtrl+K search, arrow navigation, Enter to select
  • Debug Metrics — SQL query count/time, memory usage, execution time per request

Screenshots

API Lens - Endpoint List

API Lens - Endpoint Detail

API Lens - Live Testing

API Lens - Response & Metrics

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:

  1. Set custom headers (Authorization, Content-Type, etc.)
  2. Edit JSON request body with smart defaults
  3. See response status, headers, and formatted body
  4. 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 evrenonur/api-lens 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-26