Home › Symfony › Symfony 8 CLAUDE.md

Symfony 8 CLAUDE.md

CLAUDE.md for Symfony 8 apps on PHP 8.4: attributes, autowiring, Doctrine ORM 3, DTO mapping, Messenger, and PHPUnit.

Claude Code (CLAUDE.md)Symfony

How to use

Save this as CLAUDE.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

CLAUDE.mdDownload  
# CLAUDE.md: Symfony 8

## Commands
- `symfony server:start` (or `php -S`) · `bin/console cache:clear` · `bin/phpunit` · `vendor/bin/phpstan analyse` · `vendor/bin/php-cs-fixer fix --dry-run`
- Makers: `bin/console make:entity`, `make:controller`, `make:migration`; then `bin/console doctrine:migrations:migrate` (local only).

## Conventions
- Attributes everywhere: `#[Route('/orders/{id}', methods: ['GET'])]`, Doctrine mapping attributes, `#[AsMessageHandler]`, `#[AsCommand]`.
- Services are autowired and autoconfigured; inject via constructor with `readonly` promoted properties. Don't fetch services from the container.
- Controllers are thin. Map input to DTOs with `#[MapRequestPayload]` / `#[MapQueryString]` and Validator constraints on the DTO; return `JsonResponse` or render Twig.
- Load entities with `#[MapEntity]` or repositories, and check access with voters (`#[IsGranted('EDIT', subject: 'order')]`).
- Doctrine: repositories with typed query methods; avoid N+1 with joins in DQL/QueryBuilder; write through the `EntityManager` in services, with one `flush()` per use case.
- Every schema change is a migration; review the generated SQL.
- Async work through Messenger messages (simple DTOs) and handlers; configure transports and retries in `messenger.yaml`.
- Config and secrets via env vars and `bin/console secrets:set`; never commit real `.env.local` values.
- Twig auto-escaping stays on; CSRF protection on forms.

## Tests
`WebTestCase` for HTTP, `KernelTestCase` for services, a test database reset per run. PHPStan level from the project config must stay green.

More: all Symfony rules · all Claude Code (CLAUDE.md) rules

Related rules

Bun runtime CLAUDE.md

CLAUDE.md for TypeScript projects on Bun 1.2+: bun test, Bun.serve, built-in SQLite/Postgres, and bundling.

Claude Code (CLAUDE.md)Bun

Django CLAUDE.md

CLAUDE.md for Django 5 projects with DRF, pytest-django and PostgreSQL.

Claude Code (CLAUDE.md)Django

Django models & migrations .claude/rules file

A path-scoped Claude Code rules file for Django models, migrations, and ORM queries, loaded only for those files.

Claude Code (CLAUDE.md)Django

Elixir Phoenix CLAUDE.md

CLAUDE.md for Phoenix 1.8 + LiveView 1.x apps in Elixir: contexts, Ecto changesets, and ExUnit tests.

Claude Code (CLAUDE.md)Elixir / Phoenix

Go backend CLAUDE.md

CLAUDE.md for idiomatic Go HTTP services using the standard library, sqlc and table-driven tests.

Claude Code (CLAUDE.md)Go

Go CLI (Cobra) CLAUDE.md

CLAUDE.md for command-line tools in Go 1.27 with Cobra: commands, flags, output formats, exit codes, and tests.

Claude Code (CLAUDE.md)Go

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.