bfg/laravel-boost-reflector
Composer 安装命令:
composer require bfg/laravel-boost-reflector
包简介
Laravel boost with reflection of classes
README 文档
README
Laravel Boost Reflector extends the Laravel Boost MCP server with powerful PHP class reflection and analysis capabilities. It provides three specialized tools for deep code introspection, enabling code analysis, documentation generation, refactoring planning, and architecture understanding.
Built on top of Roave BetterReflection, this package offers fast class discovery with advanced filtering, comprehensive API introspection including inherited members, and dependency usage analysis across your entire codebase—including vendor packages.
Whether you're exploring Laravel's Eloquent API, planning a major refactoring, generating documentation, or analyzing architectural dependencies, Laravel Boost Reflector provides the metadata you need with precision and performance.
Installation
Install the package via Composer:
composer require bfg/laravel-boost-reflector
The package will automatically register its MCP tools with Laravel Boost.
Available Tools
| Tool | Description |
|---|---|
| class-list | Fast discovery of PHP classes with powerful filtering by traits, interfaces, and methods |
| class-detail | Deep introspection of class structure including methods, properties, constants, and complete inheritance hierarchy |
| class-usages | Dependency analysis showing where and how classes are used throughout the codebase |
Usage Examples
class-list
Fast discovery of PHP classes with powerful filtering capabilities. Perfect for finding classes that match specific criteria like traits, interfaces, or methods.
Find all Eloquent models with HasFactory trait:
{
"path": "app/Models",
"has_trait": "Illuminate\\Database\\Eloquent\\Factories\\HasFactory"
}
Find all controllers:
{
"path": "app/Http/Controllers",
"recursive": true
}
Find classes with boot() method:
{
"path": "app",
"has_method": "boot",
"limit": 20
}
Example output structure:
[
{
"file": "/path/to/app/Models/User.php",
"name": "App\\Models\\User",
"parent": "Illuminate\\Foundation\\Auth\\User",
"interfaces": ["Illuminate\\Contracts\\Auth\\MustVerifyEmail"],
"traits": [
"Illuminate\\Database\\Eloquent\\Factories\\HasFactory",
"Illuminate\\Notifications\\Notifiable"
],
"docblock": "User model representing authenticated users"
}
]
Parameters:
path(required) - Directory to scanhas_trait- Filter by trait (full namespace)has_interface- Filter by interface (full namespace)has_method- Filter by method namerecursive- Scan subdirectories (default: true)limit- Maximum results to returnoffset- Skip first N results
Use cases:
- Find all Eloquent models with specific traits (SoftDeletes, HasFactory)
- Locate all controllers or middleware in your application
- Discover classes implementing specific interfaces (ShouldQueue, Responsable)
- Identify classes with specific methods for refactoring
class-detail
Deep introspection of any PHP class with complete API details. Returns comprehensive information about methods, properties, constants, parameters, return types, visibility, and docblocks.
Explore Eloquent Model API (including inherited methods):
{
"class": "Illuminate\\Database\\Eloquent\\Model",
"methods": true,
"include_inherited": true,
"visibility": "public",
"methods_limit": 20
}
Analyze a specific project class:
{
"class": "App\\Models\\User",
"constants": true,
"properties": true,
"methods": true,
"full_docblocks": true
}
Quick overview with summary mode:
{
"class": "App\\Services\\PaymentService",
"summary_mode": true
}
Find all static helper methods:
{
"class": "Illuminate\\Support\\Str",
"methods": true,
"static_only": true,
"visibility": "public"
}
Example output structure:
{
"name": "App\\Models\\User",
"file": "/path/to/app/Models/User.php",
"parent": "Illuminate\\Foundation\\Auth\\User",
"interfaces": ["Illuminate\\Contracts\\Auth\\MustVerifyEmail"],
"traits": ["HasFactory", "Notifiable"],
"methods": [
{
"name": "posts",
"visibility": "public",
"static": false,
"return_type": "Illuminate\\Database\\Eloquent\\Relations\\HasMany",
"parameters": [],
"docblock": "Get all posts for the user"
}
],
"properties": [
{
"name": "fillable",
"visibility": "protected",
"type": "array",
"default": ["name", "email", "password"]
}
]
}
Parameters:
class(required) - Full class namespace or file pathconstants- Include class constants (default: true)properties- Include properties (default: true)methods- Include methods (default: true)include_inherited- Show inherited members from parent classes (default: false)visibility- Filter by visibility: "public", "protected", "all" (default: "public")static_only- Show only static methods (default: false)summary- Show only summary lines in docblocks (default: true)full_docblocks- Show complete docblocks everywhere (default: false)summary_mode- Concise output for quick overview (default: false)methods_limit,methods_offset- Paginate methodsproperties_limit,properties_offset- Paginate propertiesconstants_limit,constants_offset- Paginate constants
Use cases:
- Explore complete Eloquent Model API with all inherited methods
- Understand Laravel helper classes (Str, Arr, Collection)
- Generate API documentation from class metadata
- Analyze class structure before refactoring
- Discover available methods on vendor classes
class-usages
Comprehensive dependency and usage analysis showing where and how classes are used throughout your codebase. Essential for refactoring impact analysis and understanding dependencies.
Find all usages of a specific class:
{
"target": "App\\Models\\User",
"path": "app"
}
Analyze Route facade usage:
{
"target": "Illuminate\\Support\\Facades\\Route",
"usage_types": ["import", "static_call"],
"group_by_type": true
}
Refactoring impact analysis:
{
"target": "App\\Services\\PaymentService",
"exclude_vendor": true,
"group_by_type": true
}
Find all classes extending a base class:
{
"target": "App\\Http\\Controllers\\Controller",
"usage_types": ["extends"]
}
Example output structure:
{
"target": "App\\Models\\User",
"usages": [
{
"file": "/path/to/app/Http/Controllers/UserController.php",
"line": 15,
"type": "import",
"context": "use App\\Models\\User;"
},
{
"file": "/path/to/app/Http/Controllers/UserController.php",
"line": 42,
"type": "static_call",
"context": "User::where('active', true)->get()"
}
],
"statistics": {
"total_usages": 24,
"by_type": {
"import": 8,
"static_call": 12,
"new": 4
},
"by_file": {
"/path/to/app/Http/Controllers/UserController.php": 5
}
},
"scan_stats": {
"files_scanned": 156,
"scan_time_ms": 245
}
}
Parameters:
target(required) - Full class namespace to search forpath- Directory to scan (default: "app")usage_types- Filter by types: "import", "new", "static_call", "extends", "implements", "trait", "type_hint"exclude_vendor- Skip vendor directory (default: true)flush_cache- Clear cached results before scanning (default: false)group_by_type- Group results by usage type (default: false)sort_by- Sort by: "line", "file", "type" (default: "line")limit- Maximum results (default: 100)offset- Skip first N results
Use cases:
- Refactoring impact analysis before changing a class
- Find all Route facade usages in your application
- Dead code detection (classes with zero usages)
- Understand dependency chains and coupling
- Track which classes extend or implement specific types
Common Use Cases
Architecture Analysis
Understand your application's structure by discovering all classes that implement specific interfaces or use particular traits:
{
"path": "app",
"has_interface": "Illuminate\\Contracts\\Queue\\ShouldQueue"
}
Refactoring Planning
Before refactoring a class, analyze its usage to understand the impact:
{
"target": "App\\Services\\LegacyService",
"exclude_vendor": true,
"group_by_type": true
}
Documentation Generation
Extract complete API information from classes to generate documentation:
{
"class": "App\\Services\\ApiClient",
"methods": true,
"properties": true,
"full_docblocks": true,
"visibility": "public"
}
Finding Models with Specific Traits
Discover all Eloquent models using SoftDeletes or other traits:
{
"path": "app/Models",
"has_trait": "Illuminate\\Database\\Eloquent\\SoftDeletes"
}
Laravel API Exploration
Learn what methods are available on Laravel's core classes, including inherited methods:
{
"class": "Illuminate\\Support\\Collection",
"methods": true,
"include_inherited": true,
"visibility": "public",
"static_only": false
}
Dead Code Detection
Find classes that are never used in your codebase:
{
"target": "App\\Services\\UnusedService",
"path": "app"
}
Requirements
- PHP 8.1 or higher
- Laravel Boost ^1.8
Credits
License
The MIT License (MIT). Please see License File for more information.
bfg/laravel-boost-reflector 适用场景与选型建议
bfg/laravel-boost-reflector 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「template」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bfg/laravel-boost-reflector 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bfg/laravel-boost-reflector 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bfg/laravel-boost-reflector 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple ASCII output of array data
E2E Studios PHP Framework adaptation of leafsphp/blade package
Alfabank REST API integration
Ensolab template project
Account Balance / Wallets Manager For FilamentPHP and Filament Account Builder
Render blade templates into a PSR-7 Response object.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 33
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-16