Download the PHP package mateffy/laravel-introspect without Composer
On this page you can find all versions of the php package mateffy/laravel-introspect. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mateffy/laravel-introspect
More information about mateffy/laravel-introspect
Files in mateffy/laravel-introspect
Package laravel-introspect
Short Description Analyze Laravel codebases and find structured information about models, routes and other Laravel-specific things.
License MIT
Homepage https://github.com/mateffy/laravel-introspect
Informations about the package laravel-introspect
Introspect for Laravel
A utility package to analyze Laravel codebases, querying views, models, routes, classes and more directly from your codebase using a type-safe fluent API.
- ๐ 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)
Query | Available Filters |
---|---|
Views | name, path, used by view, uses view, extends |
Routes | name, URI, controller + fn, methods, middleware |
Classes | name / namespace, extends parent, implements interfaces, uses traits |
โคท Models | ... relationships, properties, casts, fillable, hidden, read/writeable |
โคท Commands | ... signature, description (coming soon) |
Name and a few other queries even support wildcard queries (e.g.
components.*.paragraph
)
Who is this for?
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.
Installation
Install the package via composer:
[!NOTE]
Depending on your use case, it might make sense to install the package as a dev dependency by adding the--dev
flag to the command.
Usage
- Views
- Routes
- Classes
- Models
- Commands
- Chaining queries with OR and AND
Views
You can query all of the views you have in your codebase, including those that are provided by other packages and are
namespaced with a prefix::
.
View queries return a Collection<string>
of view names.
All queries support wildcards, e.g.
components.*.button
or*.button
Query views by view path
Query all views that are used by specific views
Query all views that use a specific view
Query all views that extend a specific view
Routes
Query through all the routes registered in your application (think like artisan route:list
output), including those
registered by packages.
The routes are returned as a Collection<\Illuminate\Routing\Route>
.
Query all routes that use a controller
Query all routes that use a specific middleware
Query routes by name
"Name equals/contains" queries support wildcards, e.g.
api.products.*
or*.products.*
Query routes by path
"Path equals/contains" queries support wildcards, e.g.
api/products/*
or*/products/*
Generic Classes
Query by namespace
Query by parent
Query by interface
Query by trait
Models
Query Eloquent models based on their properties, attributes (fillable, hidden, appended, readable, writable), and relationship existence. Model queries return a Collection
of model class strings (e.g., App\Models\User::class
).
Query by Property Existence
Filter models based on whether they possess specific properties.
Query by Fillable Properties
Filter models based on their $fillable
attributes.
Query by Hidden Properties
Filter models based on their $hidden
attributes.
Query by Appended Properties
Filter models based on their $appends
attributes (accessors).
Query by Readable Properties
Filter models based on "readable" properties (public getters, public properties, or attributes).
Query by Writable Properties
Filter models based on "writable" properties (public setters or public properties).
Query by Relationship Existence
Filter models based on the existence of specific relationship methods. Note: This currently checks for method presence, not relationship type or related model details.
Chaining queries with OR
and AND
By default, any queries are combined with AND
logic.
However, you can craft more complex queries by chaining together queries with OR
logic, too.
This works for all queries, including models, routes, views and classes.
Some methods support multiple parameters, e.g. whereUsesMiddlewares([...])
or whereUsesProperties([...])
.
These methods have an all
parameter that defaults to true
. If set to false
, the values are checked with OR
logic
too, matching on any of the values.
Limit the results and paginate just like using Eloquent queries
Actual Laravel pagination (->paginate(...)
) is not yet supported, but you can use limit
and offset
to get the
results you want.
DTO Examples
Get all model properties
Get Model as JSON schema
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-introspect with dependencies
illuminate/contracts Version ^10.0||^11.0||^12.0
laravel/prompts Version ^0.3.5
phpdocumentor/reflection-docblock Version ^5.6
roave/better-reflection Version ^6.57
spatie/invade Version ^2.1
spatie/laravel-package-tools Version ^1.16
spatie/php-structure-discoverer Version ^2.3