Supercharge Your PHP Workflow with Claude Code: Practical Tips for Laravel and Symfony Developers
Practical Claude Code tips for PHP developers: CLAUDE.md setup, custom agents for Laravel/Symfony, skill libraries, and MCP-powered workflows.
Claude Code has gone from a curiosity to a daily driver for a lot of PHP developers over the past several months. If you have been using it as a smarter autocomplete, you are leaving most of its value on the table. The real gains come from tuning your configuration to match how you actually work: your PHP standards, your framework conventions, your preferred debugging flow. This post walks through the practical setup that makes Claude Code genuinely useful for Laravel and Symfony projects.
Start With a Good CLAUDE.md
Every Claude Code session starts by reading a CLAUDE.md file from your home directory. This is your global instruction set, and it is the single highest-leverage thing you can configure.
A minimal but effective PHP-focused CLAUDE.md might look like this:
# Claude Code Global Instructions
## Behavior
- Be critical. Point out problems in my approach, not just the code.
- Never be sycophantic. If something is wrong, say so directly.
- Use `gh` for all GitHub operations, never raw curl.
## PHP Standards
- Target PHP 8.3+ features where appropriate.
- Follow PSR-12 coding standards.
- Prefer readonly properties, named arguments, and enums over older patterns.
- Always type method parameters and return types explicitly.
## Laravel Conventions
- Business logic lives in Service classes, injected via constructor.
- Services must not depend on Request, Session, or any HTTP-layer class.
- Use Eloquent relationships properly; avoid raw DB queries unless performance demands it.
- Form Requests for validation, never validate in controllers.
## Testing
- PHPUnit for unit tests, Pest for feature tests.
- Never mock the database in feature tests.
- Run `php artisan test` to verify before committing.
For Symfony projects, swap the Laravel section for your own doctrine conventions, service container patterns, and messenger component preferences. The point is to write this once and have Claude follow it across every project without you repeating yourself.
Freek Van der Herten, one of the most prolific Laravel package authors, shared his setup in March 2026, including a comprehensive dotfiles configuration that keeps all Claude Code config under config/claude/ for easy syncing across machines. The key insight from his setup: CLAUDE.md should be short and opinionated, not exhaustive. Think of it as a commit message for your own preferences, not a wiki.
Custom Agents for Different Contexts
Claude Code supports custom agents: pre-configured personas with specific models and system prompts. You define them in .claude/agents/ in your project or globally. Each agent gets a YAML or Markdown file with a name, model, and instructions.
A practical four-agent setup for a Laravel project looks something like this:
.claude/agents/
├── laravel-feature-builder.md
├── laravel-debugger.md
├── laravel-simplifier.md
└── task-planner.md
The laravel-feature-builder agent uses a more capable model and focuses on building out new features with full context about your architecture. The laravel-debugger agent gets a focused prompt around tracing bugs through logs, stack traces, and test failures. The laravel-simplifier reviews completed code and refactors toward readability. The task-planner breaks large features into concrete steps before any code is written.
Switching between them is a single slash command: /agent laravel-debugger. You stop re-explaining your context on every session.
Skills: Keep Context Clean
Skills are reference documents that Claude Code pulls in on demand. Instead of loading your entire PHP guidelines into every session, you define them as a skill and Claude references them when they become relevant.
A typical PHP project might have skills for:
php-guidelines.md: Your PSR standards and code style preferenceseloquent-patterns.md: Relationship conventions, scopes, eager loading rulesapi-conventions.md: Response formatting, versioning, error handlingtesting-strategy.md: What gets unit tested vs. feature tested, test naming conventions
Skills live in .claude/skills/ and stay out of the context window until needed. For a team, commit them to the repo. Every developer and every CI run gets the same context.
Connecting MCP Servers
The real unlock for PHP developers in 2026 is MCP (Model Context Protocol) server integration. Several tools now ship MCP servers that Claude Code can talk to directly.
Laravel 12’s Boost package includes an MCP server that gives Claude Code direct access to your application internals: routes, models, config, and more. In your .mcp.json:
{
"mcpServers": {
"laravel": {
"command": "php",
"args": ["artisan", "mcp:serve"]
}
}
}
Once connected, Claude can introspect your actual route list, check your model relationships, and understand your config without you pasting any of it into the chat. This eliminates an entire category of context-setting overhead.
For database work, connecting a MySQL MCP server means Claude can read your actual schema rather than relying on migration files you paste manually. It surfaces real indexes, constraints, and foreign keys.
The Status Line: Know When to Refresh
One small configuration change that makes a big practical difference is adding a custom status line to your terminal. Claude Code allows a shell script that renders at the bottom of the session, showing the current context window usage.
A straightforward bash script can output something like my-project | ctx: 34%, color-coded green below 40%, yellow up to 60%, red above that. When you see red, it is time to start a fresh conversation rather than continuing with a degraded context.
Freek Van der Herten published exactly this script in his dotfiles. It reads JSON from stdin, extracts the repo name and token count, and renders the percentage. Without it, you are flying blind on context health until Claude starts making obviously wrong assumptions.
Practical Workflow: Feature Development
For building a new feature, a workflow that consistently produces good results looks like this:
Start with the task-planner agent. Give it the feature spec and ask it to break it down into steps before any code is written. Review and adjust the plan. This catches architectural decisions early, before they are baked into code.
Switch to the feature-builder agent and execute the plan step by step, committing after each meaningful chunk. Claude Code’s ability to run php artisan commands, execute tests, and read their output means it catches its own mistakes in the same session, as long as you keep the scope manageable.
Use the simplifier agent on completed code before opening a PR. It consistently finds opportunities to use newer PHP syntax, remove unnecessary intermediate variables, and tighten method signatures.
For debugging, the debugger agent gets a focused prompt that starts from test output or log output, traces through the stack, and proposes a fix with a test to verify it. This tight feedback loop keeps the session context small and the reasoning sharp.
Use Thinking Mode on Complex Tasks
Claude Code’s thinking mode produces noticeably better results on complex architectural decisions and multi-file refactors. Enable it globally in settings.json with "thinking": { "enabled": true, "budget": "medium" }. For routine tasks like generating a migration or wiring a relationship, it is unnecessary overhead. The discipline is knowing when to reach for it.
What Not to Do
A few patterns that consistently produce poor results: asking Claude to build an entire feature in one prompt (the output will be syntactically correct and architecturally questionable), letting sessions run until the context turns red (stale context produces subtle errors), and skipping CLAUDE.md entirely (without it, Claude defaults to generic PHP patterns you will spend time correcting).
Resources
The community around Claude Code for PHP has produced several useful starting points over the past few months. The laravel-claude-agents repository has a comprehensive collection of agents and skills for Laravel, covering architecture, Eloquent, API design, testing, security, and debugging. For Symfony developers, the DEV Community has a setup guide by Javier Eguiluz that covers Symfony-specific conventions and tool integration.
The investment in configuration pays off quickly. An afternoon setting up CLAUDE.md, a handful of agents, and MCP server connections removes a significant amount of context-setting friction from every session after that.
Sources
- My Claude Code setup - Freek Van der Herten
- Adding a custom status line to Claude Code - Freek Van der Herten
- Claude Code for Symfony and PHP: The Setup That Actually Works - DEV Community
- laravel-claude-agents on GitHub
- The Complete Laravel + Claude Code Ecosystem - hafiz.dev
- How I set up Claude Code on a Laravel project - Medium
- Best practices for Claude Code - Claude Code Docs