ReflectionClass may impact performance in high-frequency inspection scenarios (e.g., per-request validation). Benchmarking recommended for production workloads.Inspector::flush() must be called explicitly in long-lived processes (e.g., queues, CLI scripts).relationships to typed objects).protected fields, computed properties)?User or Product) to validate inspection accuracy and performance.return schema(['name' => 'string']); with return schema($inspector->inspect(User::class)->toArray());.Illuminate\Support\Facades\Cache or Redis for repeated requests.ModelInspected event to trigger post-inspection logic (e.g., updating a schema registry).morphTo without additional logic.append() or $appends are included, but computed properties (PHP 8.1+) are not.composer require cerbero/eloquent-inspector
$userSchema = Inspector::inspect(App\Models\User::class);
toArray() to generate OpenAPI/Swagger specs.// In a queue job or CLI command:
Inspector::flush();
Inspector::flush() in queue:work or schedule:run commands to prevent memory bloat.model:inspect Artisan command to force re-inspection.debugbar or Prometheus metrics.Inspector::flush() or restart the PHP process.try-catch blocks around inspections to handle missing models gracefully.MODEL_INSPECTION_RULES.md file to document exceptions (e.g., "Product model excludes price from inspections").// Override inspection for specific models
Inspector::inspect(App\Models\Product::class, [
'exclude' => ['price', 'tax_rate'],
]);
Inspector::flush() per worker lifecycle).memory_get_usage() in production.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Reflection errors (e.g., missing class) | Inspection fails silently or throws exceptions. | Wrap in try-catch; log and fallback to defaults. |
| Memory exhaustion (large models) | PHP crashes or timeouts. | Set Inspector::flush() in cron jobs; limit inspected models. |
| Stale inspections (model changes) | Outdated metadata used in production. | Implement a model:updated event to trigger re-inspection. |
| Circular relationships | Infinite loops during inspection. | Use Inspector::inspect()->limitDepth(5) or exclude problematic relationships. |
| Octane/Swoole worker leaks | Memory not freed between requests. | Override Inspector singleton to clear on worker shutdown. |
CONTRIBUTING.md section for inspection patterns.@inspectable PHPDoc tags for better IDE hints.php artisan inspect:report App\Models\User
Inspector to test consumption logic without reflection overhead.How can I help you explore Laravel packages today?