LaraLens — Laravel Intelligence for VS Code

Make Laravel's implicit behavior visible.
LaraLens is a VS Code extension that statically analyzes Laravel applications and surfaces the relationships the framework usually hides: routes, middleware, Eloquent relationships, events, observers, global scopes, queues, config, env safety, N+1 risks, migrations, and more.
Built on a real PHP AST (php-parser), a normalized Laravel semantic model, and a confidence system that refuses to claim certainty where Laravel's dynamism doesn't allow it.
Features
| Area |
Status |
Route intelligence — groups, resource() / apiResource(), hover, go-to-definition, references, rename, shadowing |
✅ |
| Eloquent relationship navigator — hover, definition, FK inference, typo detection |
✅ |
| N+1 detector — loops / collections, unused eager loads |
✅ |
Event / listener explorer — $listen, Event::listen(), #[AsEventListener], subscribers |
✅ |
Observers & global scopes — Model::observe(), #[ObservedBy], addGlobalScope(), #[ScopedBy] |
✅ |
| Execution trail — route → middleware → controller → events / listeners; model implicit behavior |
✅ |
| Query Builder Visualizer — FROM / WHERE / eager load / order / pagination + estimated SQL |
✅ |
| Explain Laravel — deterministic step-by-step chain explanation |
✅ |
Config intelligence — config() ↔ config/*.php |
✅ |
Environment safety — env() outside config, .env vs .env.example |
✅ |
| Migration risk analyzer — drop/rename column, NOT NULL without default |
✅ |
| Queue intelligence — queue, tries, timeout, backoff, dispatch sites |
✅ |
| Dead code detector — routes, controllers, jobs, commands, policies, middleware, Blade components (DEFINITE / PROBABLE / DYNAMIC) |
✅ |
| Dependency graph — interactive webview, pan / zoom / click-to-source |
✅ |
| API contract checker — resource field shapes, route correlation, test mismatches |
✅ |
| Test coverage mapper — HTTP tests + PHPUnit Clover/Cobertura import |
✅ |
Scheduled tasks — Schedule::command/call/job + frequency helpers |
✅ |
Translations & Blade — key navigation, @lang / __() references |
✅ |
| Runtime telemetry |
✅ VS Code receiver + runtime-agent Laravel package (opt-in, local-only) |
Confidence levels: HIGH / DEFINITE, MEDIUM / PROBABLE, LOW / DYNAMIC. LaraLens never turns uncertainty into a definitive warning.
Requirements
- VS Code 1.85 or later
- A workspace that contains a Laravel app (
artisan + composer.json)
- No PHP runtime required — analysis is static; your application code is never executed
Quick start
- Install the extension from the VS Code Marketplace (or package from source — see below).
- Open a Laravel project.
- Run LaraLens: Analyze Workspace from the Command Palette (
Ctrl+Shift+P / Cmd+Shift+P).
- Use the LaraLens activity-bar views (Routes, Models, Events, Dead Code, Findings) and editor features (hover, go-to-definition, CodeLens, diagnostics).
Commands
All commands are prefixed with LaraLens: in the Command Palette:
| Command |
Purpose |
| Analyze Workspace |
Full incremental index + diagnostics |
| Refresh Index |
Re-index changed files |
| Show Route / Route Graph |
Route details and graph |
| Show Dependency Graph |
Architecture graph |
| Show Event Flow |
Event → listeners |
| Show Execution Trail |
Static request / event trail |
| Show Model Implicit Behavior |
Scopes, observers, relationships |
| Show Query Visualizer |
Query breakdown + estimated SQL |
| Explain Laravel / Explain Query |
Step-by-step chain explanation |
| Find Dead Code |
Open dead-code tree |
| Analyze Migration |
Migration risk report |
| Analyze API Contract |
Resource field / route report |
| Show Test Coverage |
Route ↔ HTTP test mapping |
| Import PHPUnit/Clover Coverage |
Line coverage from Clover/Cobertura XML |
| Start / Stop Runtime Tracking |
Opt-in local telemetry |
Configuration
| Setting |
Default |
Description |
laralens.analysis.enableNPlusOne |
true |
N+1 detection |
laralens.analysis.enableDeadCode |
true |
Dead-code diagnostics |
laralens.analysis.enableRuntime |
false |
Opt-in runtime bridge |
laralens.analysis.confidenceThreshold |
low |
Minimum confidence to surface |
laralens.paths.app / .routes / … |
Laravel defaults |
Override non-standard layouts |
laralens.analysis.exclude |
[] |
Extra glob excludes |
See docs/configuration.md for the full list.
Privacy & security
- No source code leaves your machine for core analysis.
- Runtime telemetry is opt-in, local-only, and never collects secrets, tokens, cookies, or request bodies by default.
.env values are never shown in diagnostics, graphs, or logs.
Details: docs/security.md · docs/runtime.md
Develop from source
git clone https://github.com/AnandShah10/LaraLens.git
cd LaraLens
npm install
npm run compile # type-check
npm run build # bundle dist/extension.js
npm test # vitest suite
npm run lint
Press F5 in VS Code to launch an Extension Development Host, or package with:
npx @vscode/vsce package
Architecture notes: ARCHITECTURE.md · Implementation status: ROADMAP.md
Project layout
src/
analysis/ # Indexer, semantic model, analyzers
explanations/ # Explain Laravel, Query Visualizer, Execution Trail
graph/ # Reusable graph engine
providers/ # Hover, Definition, References, CodeLens, Diagnostics
ui/ # Tree views & webview panels
runtime/ # Opt-in local telemetry client
php/ # AST / parser integration
test/
fixtures/ # Small Laravel apps for integration tests
unit/ integration/
Contributing
Issues and PRs are welcome. Prefer small, correct analyzers over broad but noisy ones. Keep false-positive rates low and preserve the confidence model.
License
MIT
Made with ❤️ by Anand Shah for Developer Community
| |