Download the PHP package laramint/laravel-brain without Composer
On this page you can find all versions of the php package laramint/laravel-brain. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download laramint/laravel-brain
More information about laramint/laravel-brain
Files in laramint/laravel-brain
Package laravel-brain
Short Description Visualize your Laravel request lifecycle as an interactive graph
License MIT
Informations about the package laravel-brain
Visualize your Laravel application's full request lifecycle as an interactive graph.
Understand how routes, controllers, services, models, jobs, events, commands, and channels connect — in seconds.
What is LaraMint\LaravelBrain?
LaraMint\LaravelBrain is a zero-config developer tool that analyzes your Laravel codebase and renders an interactive node graph of your application's architecture. It traces every route through its controller, services, repositories, models, jobs, events, Artisan commands, scheduled tasks, broadcast channels, and Filament panels — giving you a bird's-eye view of the entire application without reading a single line of code.
The scan writes JSON graph files to storage/app/laravel-brain/. The viewer is served at /_laravel-brain entirely through your existing Laravel routes — no separate server process needed.
Features
- Full lifecycle tracing — Follows every route from HTTP verb → controller → service → repository → model → events/jobs
- Filament PHP support — Discovers panels, resources, pages, widgets, and relation managers; traces call chains from Filament page methods the same way controller actions are traced
- Artisan command discovery — Maps class-based commands, closure commands from
routes/console.php, and Kernel-registered commands - Scheduler tracing — Visualizes scheduled tasks (
command,job,call) with their frequency - Broadcast channel mapping — Discovers class-based and closure channels from
routes/channels.php - DB query tracing — Surfaces Eloquent and raw queries per method
- Fat-class detection — Flags controllers and services with more than 300 lines or 10 methods
- Cyclomatic complexity — Highlights hotspots by complexity tier (Low / Moderate / High / Critical)
- Interactive graph — Dark/light theme, accent-colored nodes, and interactive edges
- Per-route tabs — Each route gets its own isolated subgraph tab
- Middleware mapping — Shows which middleware guards each route
- Model relationships — Displays
hasMany,belongsTo, and other Eloquent relations - Method flowcharts — See internal flow as a step-by-step diagram with a large modal popup view
- Sequence diagrams — Route nodes render an SVG sequence diagram (exportable as PNG or Mermaid) showing the full actor chain
- Source viewer — Read the actual source file inline or in a focused popup
- Export — Export any graph as PNG or Mermaid diagram
- Multiple layouts — Hierarchical (dagre), force-directed (cose-bilkent), breadth-first, circle, grid
- Watch mode — Auto-rescans on PHP file changes
- Route stress test — From a selected route node, run concurrent HTTP load against that endpoint (via
laramint/laravel-stress): configure request count, concurrency, headers, body, and timeout; see timing percentiles (min/avg/p50/p95/p99/max), throughput, and status distribution in the sidebar. While a run is active, the graph highlights the route and animates packets along the request path - AI context export — Copy a deterministic, token-optimized context snapshot for any node to your clipboard with one click (🤖 button in the sidebar). Also available as
brain:export-contextArtisan command andGET /_laravel-brain/api/contextAPI endpoint. Context includes call chain, complexity hotspots, DB operations, source snippets, and all backend/frontend packages — always reproducible from the same scan data - AI rules generation — Generate ready-to-use context files for seven AI coding assistants (Claude Code, Cursor, Windsurf, GitHub Copilot, JetBrains Junie, Aider, AGENTS.md) directly from the UI (Export → Generate AI Rules) or via
brain:generate-rules. Each file is populated with your project's real architecture, routes, packages, and code-health data
Requirements
- PHP 8.0+
- Laravel 9, 10, 11, 12, or 13
- Composer
Installation
Install as a dev dependency (it's a development tool, not needed in production):
Laravel will auto-discover the service provider. No manual registration needed.
Usage
Scan your project
This analyzes your entire codebase and writes the graph data to storage/app/laravel-brain/. When complete it prints the URL to open:
Memory limit
The scanner defaults to 1024M. On larger codebases you can raise the limit with --memory-limit:
Accepted formats: <number>M (megabytes), <number>G (gigabytes), or -1 (unlimited). The minimum allowed value is 1024M.
Export AI context for a node
Click the 🤖 button in the node sidebar to copy a structured Markdown context block to your clipboard, ready to paste into Claude, ChatGPT, or any LLM.
The context is deterministic: same scan + same node = identical output every time. It uses BFS up to depth 3 from the selected node and enforces a token budget (default 6 000 tokens), truncating only source snippets once structural metadata is fully included.
You can also run it from the terminal:
Or via the API:
The exported Markdown contains:
- Route — method, URI, middleware
- Call chain —
Route → Controller → Service → Model(depth ≤ 3) - Complexity hotspots — cyclomatic complexity + line count table
- Database operations — Eloquent and raw queries per node
- Source snippets — focal node first, truncated to fit the token budget
- Backend packages — all
composer.jsondependencies with versions, dev flag - Frontend packages — all
package.jsondependencies with versions, dev flag
Generate AI assistant rules files
Populate context files for your AI coding tools directly from the scan data.
From the UI: Toolbar → Export → Generate AI Rules → select targets → Generate.
From the terminal:
| Target | File written | Used by |
|---|---|---|
claude |
CLAUDE.md |
Claude Code CLI & IDE extension |
cursor |
.cursor/rules/laravel-brain.mdc |
Cursor (MDC format with frontmatter) |
windsurf |
.windsurf/rules/laravel-brain.md |
Windsurf by Codeium |
copilot |
.github/copilot-instructions.md |
GitHub Copilot (applied repo-wide) |
junie |
.junie/guidelines.md |
JetBrains AI / Junie |
aider |
CONVENTIONS.md |
Aider (aider --read CONVENTIONS.md) |
agents |
AGENTS.md |
Universal open standard — 60+ tools |
Each generated file contains your project's tech stack, architecture counts, top routes, complexity hotspots, detected code smells, and full package lists. Re-run after every scan to keep the files current.
Watch mode
Re-scan automatically whenever a PHP file changes:
Open the viewer
Navigate to /_laravel-brain in your browser while your Laravel app is running (e.g. via php artisan serve).
How It Works
Route discovery
LaravelBrain recursively scans your entire routes/ directory — not just web.php and api.php. Any PHP file under routes/** is analyzed, including versioned files like routes/v1/users.php or module-specific files like routes/modules/admin.php.
Auto-discover mode
Set 'auto_discover_routes' => true in config/laravel-brain.php to skip AST parsing and pull routes from the live Laravel router (Route::getRoutes()) instead. This captures routes registered programmatically by service providers and packages (Filament, Sanctum, Livewire, Telescope, etc.) that the AST scanner can't see.
By default, routes whose handler (controller class or closure) lives under your project's vendor/ directory are excluded — so package-internal routes such as Telescope, Horizon, or Ignition stay out of the graph. Flip 'auto_discover_exclude_vendor' => false if you want them included.
Heads up: in auto-discover mode the source file and line number of each route are not available, so the sidebar will not group routes by their declaring file (everything falls under a single group). Use the default AST mode if file/line grouping matters to you.
Call chain tracing
From each controller action (and Filament page method), the tracer follows:
- Direct method calls to injected services/repositories
- Static calls (
MyService::method()) - Job dispatches (
dispatch(new SendEmail(...))) - Event dispatches (
event(new OrderPlaced(...)))
This produces the full edge list used to build the graph.
Filament PHP support
When Filament is installed, the scanner discovers every panel registered via service providers, then resolves its resources, pages, widgets, and relation managers — both explicitly listed (->resources([...])) and auto-discovered (->discoverResources(for: '...')). Filament page methods are traced through the same call-chain engine as controller actions, so models and services they touch appear in the graph.
Graph Node Types
| Node | Accent Color | Represents |
|---|---|---|
| Route | Green #4CAF50 |
HTTP endpoint (GET /users) |
| Middleware | Orange #FF9800 |
Middleware applied to a route |
| Controller | Blue #2196F3 |
Controller class |
| Action | Light Blue #03A9F4 |
Controller method |
| Service | Purple #9C27B0 |
Service or helper class |
| Model | Red #F44336 |
Eloquent model |
| Event | Yellow #FFD600 |
Laravel event |
| Job | Slate #607D8B |
Queued job |
| Filament Panel | Violet #7C3AED |
Filament panel definition |
| Filament Resource | Purple #A855F7 |
Filament resource class |
| Filament Page | Lavender #C084FC |
Filament page class |
| Filament Page Method | Pink #E879F9 |
Method on a Filament page |
| Filament Widget | Cyan #06B6D4 |
Filament widget class |
| Filament Relation Manager | Teal #0891B2 |
Filament relation manager |
Note: Command, Schedule, Channel, and Repository nodes are discovered and added to the graph but use the closest matching accent color from their parent type.
Viewer Shortcuts
| Action | How |
|---|---|
| Zoom | Scroll wheel |
| Pan | Click + drag on canvas |
| Inspect node | Click any node |
| View source | Click a node → Source tab in sidebar |
| Source popup | Click ⤢ in source section to open focused view |
| View flowchart | Click a class node → Flow tab |
| Flowchart popup | Click ⤢ in flow section to open large view |
| View sequence diagram | Click a route node → Sequence Diagram section in sidebar |
| Filter by type | Filter panel on the left |
| Fit all nodes | Toolbar → Fit button |
| Export PNG | Toolbar → Export → Download PNG |
| Export Mermaid | Toolbar → Export → Copy Mermaid Code |
| Generate AI rules | Toolbar → Export → Generate AI Rules |
| Toggle theme | Toolbar → ☀️ / 🌙 button |
| Copy AI context | Click any node → 🤖 button in sidebar header |
| Stress test a route | Click a route node → open Stress Test in the sidebar → set options → Run |
Routes Registered
The package registers the following routes in your application (all under the /_laravel-brain prefix):
Stress testing uses laramint/laravel-stress, which is installed automatically as a dependency. Target URLs are validated server-side against an allowlist of development hosts: localhost, 127.0.0.1, *.test, *.local, *.ddev.site, single-label Docker service names (e.g. nginx, app), private IPv4 ranges (10.x, 172.16–31.x, 192.168.x), and the host in APP_URL.
Docker and stress testing
Docker? The stress test subprocess runs inside the container —
localhost:8080is the host-side mapped port and won't be reachable there. Change the Base URL field to the internal service address, e.g.http://nginxorhttp://localhost:80.
Single-label hostnames (Docker service names with no dots) and private IPv4 ranges are automatically allowed by the host validator, so pointing the Base URL at your internal network address will work without any extra config.
Output Files
After running brain:scan, the following files are written to storage/app/laravel-brain/:
These files are regenerated on every scan and are safe to gitignore:
Security
The /_laravel-brain routes are only registered in the local environment by default. Since it's a require-dev dependency, it will not be present in production builds (composer install --no-dev).
If you do install it in a non-production environment accessible over a network, consider protecting the routes with middleware.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you'd like to change.
Tests:
License
MIT — see LICENSE for details.
All versions of laravel-brain with dependencies
nikic/php-parser Version ^5.0
illuminate/console Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^9.0|^10.0|^11.0|^12.0|^13.0
laramint/laravel-stress Version ^1.0