Claude Code for PHP & Laravel Development: The Complete 2026 Guide
Set up Claude Code for PHP and Laravel projects with Laravel Boost MCP, the official Laravel plugin, and proven workflows for migrations, Eloquent, testing, and refactoring.
Claude Code for PHP & Laravel Development: The Complete 2026 Guide
PHP has spent a decade fighting the "legacy language" label, and Laravel has spent that same decade proving the label wrong. Now the framework has an unusual advantage in the AI-coding era: an official Laravel Boost MCP server built specifically to make AI agents like Claude Code productive inside a Laravel codebase. If you're writing PHP in 2026 and still treating Claude Code like a generic autocomplete tool, you're leaving most of the value on the table.
This guide covers what actually works: installing Laravel Boost, using the official Laravel Claude Code plugin, and the day-to-day workflows — migrations, Eloquent debugging, test generation, and legacy refactors — that make Claude Code feel like it actually understands your app/ directory instead of guessing at it.
Why Laravel + Claude Code Is a Better Fit Than You'd Expect
Most AI coding assistants treat PHP the way they treat any other language: read the files, infer the framework, hope for the best. That approach breaks down fast in Laravel, because so much of the framework's power is implicit — service container bindings, facades resolving to concrete classes, Eloquent relationships defined in one file and used three directories away, route model binding that never appears in a controller signature.
Two things changed that dynamic:
laravel/claude-code plugin — which bundles a "Simplifier" agent, testing conventions, and CI-aware review behavior tuned to Laravel idioms.Together they mean Claude Code isn't parsing your Eloquent models and guessing what $this->belongsToMany() returns — it can query your actual application state through Boost's MCP tools: routes, schema, config, even a live Tinker session.
Setting Up Laravel Boost with Claude Code
Laravel Boost runs as an MCP server directly from your Laravel installation, so Claude Code talks to your real application instead of a static snapshot of your files.
Step 1: Install Boost
bashcomposer require laravel/boost --dev
php artisan boost:installThis registers Boost as a dev dependency and walks you through detecting which AI tools you use (Claude Code, Cursor, etc.), so the install step also writes the right MCP config for you.
Step 2: Register the MCP server with Claude Code
If the installer didn't auto-register it, add Boost manually:
bashclaude mcp add laravel-boost -- php artisan boost:mcpClaude Code will now start php artisan boost:mcp on demand and gain access to Boost's tool set — routes, Eloquent models, migrations, config values, logs, and a live tinker execution tool.
Step 3: Verify the connection
Inside a Claude Code session in your project root, ask something only Boost could answer accurately:
What routes hit the OrderController, and which middleware do they run through?If Claude returns real route names and middleware groups instead of a guess based on file names, Boost is wired up correctly.
What Boost actually exposes
| Tool category | What it gives Claude Code |
|---|---|
| Routes | Full route list with methods, middleware, controller bindings |
| Database schema | Live table/column structure, not just migration files |
| Eloquent models | Relationships, casts, scopes as actually resolved |
| Tinker | Execute real PHP in your app context and read the output |
| Logs | Tail recent application logs during debugging |
| Laravel docs | 17,000+ indexed Laravel-ecosystem docs, version-aware |
The docs tool matters more than it sounds: Boost knows which Laravel version you're on and won't suggest a Http::pool() pattern from Laravel 9 when you're running Laravel 12.
Installing the Official Laravel Claude Code Plugin
Separately from Boost (which is an MCP data source), Anthropic and Laravel ship a Claude Code plugin that changes how Claude behaves in a Laravel repo — conventions, review posture, and a dedicated refactoring agent.
bashclaude plugin install laravel-boostor, if installing the broader Laravel plugin bundle from the marketplace:
bashclaude plugin marketplace add laravel/claude-code
claude plugin install laravel-simplifierThe bundled Simplifier agent is worth calling out specifically — it's scoped to refactor PHP/Laravel code for clarity and consistency without changing behavior, which is a safer default than a general-purpose refactor prompt when you're touching production billing logic or auth flows.
Core Workflows That Actually Save Time
1. Migrations that match your existing schema conventions
Instead of writing a migration and asking Claude to "make it better," let Boost's schema access do the heavy lifting:
Add a `refunded_at` nullable timestamp to the orders table,
following the same migration style as our last three migrations
in database/migrations/.Because Claude can see your actual schema via Boost, it won't invent a column name that collides with something already there, and it'll match your naming conventions (snake_case timestamps, index patterns) instead of defaulting to generic Laravel scaffolding.
2. Debugging Eloquent N+1 queries and relationship bugs
The /api/orders endpoint is slow. Use tinker to check for N+1 queries
on OrderResource and suggest eager-loading fixes.With Tinker access, Claude can actually execute Order::with('items')->get() in your app context and compare query counts before proposing a fix — not just pattern-match on ->items calls in the codebase.
3. Generating tests that match your test suite's shape
Laravel projects vary wildly between Pest and PHPUnit, feature vs. unit test emphasis, and factory conventions. Point Claude at an existing test file first:
Write a feature test for the RefundController@store method,
matching the style in tests/Feature/OrderControllerTest.php4. Legacy PHP modernization
For pre-Laravel or old-Laravel codebases (think Laravel 5.x or vanilla procedural PHP), use plan mode before touching anything:
/plan Modernize UserRepository.php to use constructor property
promotion, readonly properties, and typed returns — PHP 8.3 target.
Don't change public method signatures.Planning first matters more in PHP than most languages, because loosely-typed legacy code hides behavioral assumptions that only show up once you try to add strict types.
Claude Code vs. Generic AI Autocomplete for PHP
| Capability | Generic AI autocomplete | Claude Code + Laravel Boost |
|---|---|---|
| Sees live DB schema | No — inferred from migration files | Yes — queries actual schema |
| Understands service container bindings | Rarely | Yes, via app introspection |
| Executes code to verify a fix | No | Yes, via Tinker MCP tool |
| Version-aware Laravel docs | No | Yes — 17,000+ indexed, version-pinned |
| Multi-file refactor planning | Limited | Yes — plan mode + Simplifier agent |
| Runs your test suite before proposing done | No | Yes, via Bash tool in-session |
Writing a CLAUDE.md That Actually Helps in a Laravel Repo
A project-level CLAUDE.md at your repo root is the single highest-leverage file you can add, because it removes the need to re-explain context every session. For a Laravel project, keep it short and specific:
markdown# Project: [App Name]
## Stack
- Laravel 12, PHP 8.3
- Pest for testing (not PHPUnit) — use `it()` syntax
- Laravel Pint for formatting — run `./vendor/bin/pint` before finishing
- Livewire 3 for interactive components, Blade elsewhere
## Conventions
- Repositories in app/Repositories, not direct Eloquent calls in controllers
- All API responses go through API Resources, never raw model arrays
- Feature tests live in tests/Feature, mirroring the route structure
## Do not
- Add new packages without asking first
- Modify migrations that have already run in staging/productionClaude Code reads this automatically at the start of every session in the directory, so decisions like "we use Pest, not PHPUnit" stop being something you repeat in every prompt. This matters more in PHP than in most ecosystems, because Laravel's flexibility means two equally "correct" implementations of the same feature can look nothing alike — and without a style anchor, Claude will default to whatever pattern is most common in its training data rather than what your team actually uses.
Handling Multi-Tenant and Package-Heavy Laravel Apps
Larger Laravel codebases — multi-tenant SaaS apps, or projects leaning on packages like Filament, Spatie's permission package, or Livewire heavily — benefit from a slightly different approach. Boost's documentation tool indexes package-specific docs alongside core Laravel docs, so Claude can reason about spatie/laravel-permission role checks or Filament resource classes without you pasting in package source code.
For multi-tenancy specifically, be explicit about your isolation strategy up front:
This app uses single-database multi-tenancy with a `tenant_id` column
on every tenant-scoped table, enforced via a global scope in
App\Models\Concerns\BelongsToTenant. When adding new models, always
apply that trait and never write raw queries that skip the scope.Skipping this step is the single most common way AI-assisted Laravel work introduces a real security bug — a new table or query path that quietly bypasses tenant isolation. Treat it the same way you'd treat a code review checklist item, because that's effectively what it is.
Running the Test Suite Before You Trust the Output
Claude Code can run shell commands directly in a session, which means the loop for any non-trivial change should always end with the test suite, not with reading the diff and eyeballing it:
bash./vendor/bin/pint --test
./vendor/bin/pestAsk Claude to run both after any change and paste the output back into the conversation rather than just describing what it changed. For Eloquent-heavy changes, also ask it to run a quick Tinker check against a real (non-production) database connection — a passing test suite doesn't always catch a migration that silently drops data on a column rename.
Common Mistakes to Avoid
- Skipping Boost and relying on file-reading alone. Claude Code without Boost can still write decent Laravel code, but it will occasionally hallucinate a relationship or config key that doesn't exist. Boost closes that gap.
- Letting Claude touch migrations already run in production without a plan step. Always ask for a plan on destructive schema changes — column drops, renames, type changes — before executing.
- Not pointing Claude at an existing file for style. Laravel's flexibility means two features can look completely different. Anchor every request to a real example in your repo.
- Ignoring
.claude/CLAUDE.md. A short project file documenting your PHP version, testing framework (Pest vs. PHPUnit), and code style (Laravel Pint config) saves re-explaining context every session.
Key Takeaways
- Laravel Boost is a first-party MCP server that gives Claude Code live access to your app's routes, schema, Eloquent models, and Tinker — not just static file reads.
- The official
laravel/claude-codeplugin adds a Simplifier refactoring agent and Laravel-aware review conventions on top of Boost's data access. - Use plan mode for schema changes and legacy modernization; anchor test and migration requests to existing files in your repo for consistent style.
- The combination turns Claude Code from "PHP autocomplete" into something that reasons about your actual running application.
Next Steps
Prepping for a Claude certification while you build? AI for Anything's Claude Certified Architect practice tests cover exactly this kind of tool-use and MCP-integration reasoning that shows up on the exam — start with a free sample question set before you sit the real thing.
Ready to Start Practicing?
300+ scenario-based practice questions covering all 5 CCA domains. Detailed explanations for every answer.
⚡ Get the hottest AI insights, daily
One short email a day — the AI news, tools, and how-tos that actually matter. Plus, be first to hear when the personalized 30-Day AI Mastery Challenge launches.