Laravel Brain: Visualize Your Application's Request Lifecycle

Published on by

Laravel Brain is a package that scans your Laravel application and renders an interactive graph of how requests flow through it. Install it, run the scan, and you'll get a visual map of your routes, controllers, services, repositories, models, jobs, events, Artisan commands, scheduled tasks, and broadcast channels—all in one place.

Main features:

  • Interactive lifecycle graph — Visualizes every route through controllers, services, models, jobs, and events as an interactive node graph with multiple layouts and dark/light themes.
  • AI context export — One-click (or brain:export-context) copies a structured Markdown snapshot of any node's call chain, DB ops, and source snippets for pasting into any LLM.
  • AI rules file generation — Generates context/rules files for seven AI coding assistants (Claude Code, Cursor, Windsurf, Copilot, Junie, Aider, AGENTS.md) from your real architecture data.
  • Route stress testing — Run concurrent HTTP load tests against any route node with configurable concurrency, headers, and body; see timing percentiles while the graph animates live.
  • Watch mode + fat-class detection — Auto-rescans on PHP file changes and flags controllers or services exceeding 300 lines or 10 methods as complexity hotspots.

The graph is served directly through your Laravel app at /_laravel-brain, so there's nothing extra to set up or deploy separately.

Interactive Graph

Each route, controller action, service, model, job, and event appears as a colored node with arrows showing how data moves between them. You can click any node to inspect its details, view the source code inline, or pull up a flowchart of the method's internal logic.

Routes are organized into their own tabs so you can focus on a single endpoint without wading through the whole application at once. You can export graphs as PNG or Mermaid diagrams and choose from several layouts—hierarchical dagre, force-directed, breadth-first, circle, or grid. Dark and light themes are included, and the viewer will flag "fat classes" (controllers or services with more than 300 lines or 10 methods) as a quick sanity check on code health.

AI Context Export

One handy feature is the ability to copy a context snapshot for any node directly to your clipboard. The exported Markdown includes the route, call chain up to three levels deep, complexity hotspots, database operations per node, source snippets, and your full composer.json and package.json dependency lists—formatted to paste straight into an AI coding tool.

You can also generate it from the terminal:

# Full project summary
php artisan brain:export-context
 
# Focused on a specific route
php artisan brain:export-context --route="GET /users" --budget=4000

The same data is available via the API at GET /_laravel-brain/api/context.

AI Rules Generation

The package can also generate context files for seven AI coding assistants from your scan data:

php artisan brain:generate-rules --target=claude --target=cursor

Each supported tool gets its own rules file, populated with your project's actual architecture, routes, packages, and code health data rather than generic boilerplate.

You can find full installation instructions and the source code on GitHub.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Tinkerwell

Enjoy coding and debugging in an editor designed for fast feedback and quick iterations. It's like a shell for your application – but with multi-line editing, code completion, and more.

Visit Tinkerwell
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $9500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech

The latest

View all →
Find the Security Vulnerabilities in Your Laravel App with Sensagraph image

Find the Security Vulnerabilities in Your Laravel App with Sensagraph

Read article
Uvora: A macOS Menu Bar App for Finding Laravel Projects image

Uvora: A macOS Menu Bar App for Finding Laravel Projects

Read article
Passwordless Sign-In with Fortify Two-Factor Support in Laravel image

Passwordless Sign-In with Fortify Two-Factor Support in Laravel

Read article
Intercept: Middleware Guardrails for Laravel AI Agents image

Intercept: Middleware Guardrails for Laravel AI Agents

Read article
AI Review for Laravel Upgrades image

AI Review for Laravel Upgrades

Read article
HTTP Query Method Support in Laravel 13.19 image

HTTP Query Method Support in Laravel 13.19

Read article