With the Laravel Introspect package, you can analyze Laravel codebases, querying views, models, routes, classes, and more directly from your codebase using a type-safe fluent API:
Are you working on a complex refactoring job and need to find all the places where a specific view is used? Are you building devtools or other things which need information about the codebase? Do you need structured schema information of your Eloquent data model?
These are all use cases where you need to introspect your codebase and find out where things are used, how they are used, and what they are. This package does exactly that.
Using this package, you can query a Laravel application's codebase programmatically to find specific views, routes, classes, models, and more:
use Mateffy\Introspect\Facades\Introspect; $views = Introspect::views() ->whereNameEquals('components.*.button') ->whereUsedBy('pages.admin.*') ->get(); $routes = Introspect::routes() ->whereUsesController(MyController::class) ->whereUsesMiddleware('auth') ->whereUsesMethod('POST') ->get(); $classes = Introspect::classes() ->whereImplements(MyInterface::class) ->whereUses(MyTrait::class) ->get(); $models = Introspect::models() ->whereHasProperties(['name', 'email']) ->whereHasFillable('password') ->get(); // Access Eloquent properties, relationships, casts, etc. directly$detail = Introspect::model(User::class); // Model to JSON schema$schema = $detail->schema();
Main Features
- Query views, routes, classes, and models with a fluent API
- Use wildcards (*) to match multiple views, routes, classes, and models
- Parse properties, relationships + their types, and more directly from Eloquent model code
- (De-)serialize queries to/from JSON (perfect for LLM tool calling)
π¨βπ» Check it out on GitHub: capevace/laravel-introspect