CLAUDE.md is the long-form AI assistant guide for this repository. It provides
project context, architecture expectations, workflow conventions, and practical
rules for making Symfony backend changes that stay aligned with repository
standards.
This repository is a production-ready Symfony JSON REST API backend template with Docker setup for local development. It is designed to be consumed by frontend applications or other backend services.
Table of Contents ᐞ
- What is this
AI documentation map ᐞ
Use the repository AI guidance in this order:
.github/copilot-instructions.md- short repository-level operational rulesCLAUDE.md- long-form project context, architecture, and workflow notesdoc/AI_RULES.md- AI policy maintenance and CI strategy guidance.github/pull_request_template.md- human review checklist for pull requests
If one of these documents drifts from the implementation, prefer the actual repository code, scripts, and CI configuration as the source of truth.
Version sources of truth ᐞ
To avoid documentation drift, this file intentionally avoids mirroring most exact dependency and tooling versions.
For current versions, use these files as the source of truth:
composer.jsonfor PHP, Symfony, Doctrine, and all package versionsDockerfileandDockerfile_devfor container PHP and base image versionsphpstan.neon.distfor PHPStan level and configurationpsalm.xmlfor Psalm configurationecs.phpfor ECS (Easy Coding Standard) rulesphpunit.xml.distfor PHPUnit configuration
If a version matters for implementation, read it from those files instead of copying it into long-form documentation.
Project Architecture ᐞ
- Type: JSON REST API Backend
- Pattern: Resource-based REST architecture with service layer
- Authentication:
- JWT (Lexik JWT Bundle)
- API key authentication
- ORM: Doctrine ORM with migrations
- Migrations located in
migrations/ - Entities in
src/Entity/ - Repositories in
src/Repository/ - MariaDB database
- Migrations located in
- Key Layers:
- Controller Layer:
src/Controller/andsrc/Rest/ - Service Layer:
src/Service/andsrc/Resource/ - Repository Layer:
src/Repository/ - Entity Layer:
src/Entity/ - DTO Layer:
src/DTO/ - Security Layer:
src/Security/ - AutoMapper:
src/AutoMapper/ - Value Resolvers:
src/ValueResolver/ - Decorators:
src/Decorator/
- Controller Layer:
Development Tools ᐞ
Static Analysis ᐞ
- PHPStan (Level: max) - Static analysis
- Psalm - Static analysis with type checking
- PHP_CodeSniffer - Code style checking
- ECS (Easy Coding Standard) - Code style fixing (primary)
- PHPInsights - Code quality and architecture analysis
- Rector - Automated code refactoring and upgrades
Test runners ᐞ
- PHPUnit - Unit and integration testing
- Fastest - Parallel test execution (this will be removed in future)
- Infection - Mutation testing (not used heavily, optional)
Code Quality & Analysis ᐞ
- PHPMetrics - Code metrics and quality reports
- PHPLint / PHP-Parallel-Lint - Syntax checking
- PHPLOC - Project size and statistics
- Composer Tools - Dependency analysis
Common Development Commands ᐞ
Container Management ᐞ
make start- Start all containers (foreground, preferred way)make daemon- Start all containers (background)make stop- Stop all containersmake logs- View container logsmake bashormake fish- Get shell inside PHP container- The primary container for project commands is the
phpservice container (symfony-backend-php-fpm). - If containers are not running, start them from project root with
make startormake daemon. - Use the running
phpcontainer or IDE Dev Container as the default execution environment for project commands. - Do not execute project PHP tooling directly on the host by default; use
container-aware
maketargets or run inside thephpcontainer. - Node.js tooling is available in the containerized environment via
nvm; usemake lint-markdownfor markdown/documentation checks. - Host fallbacks for project tooling are allowed only when container execution is unavailable, and that blocker must be stated explicitly in the handoff.
Code Quality ᐞ
make phpcs- Run PHP CodeSniffermake phpstan- Run PHPStan static analysismake psalm- Run Psalm static analysismake ecs- Check code stylemake ecs-fix- Fix code style issues automaticallymake phplint- Run PHPLintmake php-parallel-lint- Run php-parallel-lintmake phploc- Run PHPLoc metrics summarymake lint-markdown- Lint Markdown documentation filesmake phpinsights- Run comprehensive code quality checksmake check-security- Check installed dependencies for known vulnerabilities
Testing commands ᐞ
make run-tests- Run all tests (single thread)make run-tests-phpdbg- Run all tests via phpdbgmake infection- Run mutation testing (not heavily used)
Database ᐞ
bin/console doctrine:migrations:migrate- Run migrationsbin/console doctrine:migrations:diff- Generate migration from entity changesbin/console doctrine:schema:validate- Validate database schema
Dependencies ᐞ
make update- Update composer dependenciesmake check-dependencies-patch- Check for patch updatesmake check-dependencies-minor- Check for minor updatesmake check-dependencies-latest- Check for latest versionsmake check-security- Check for security vulnerabilities
Development Workflow ᐞ
Adding New REST Endpoints ᐞ
This project uses a resource-based approach:
- Create/modify entity in
src/Entity/ - Generate migration:
bin/console doctrine:migrations:diff - Review and edit migration file if needed
- Run migration:
bin/console doctrine:migrations:migrate - Create/update DTO(s) in
src/DTO/ - Create/update repository in
src/Repository/ - Create/update resource class in
src/Resource/ - Create/update REST controller in
src/Rest/ - Write tests in appropriate
tests/subdirectory - Run tests:
make run-tests - Check static analyzers:
make phpcs,make ecs,make phplint,make php-parallel-lint,make psalm,make phpstan,make phploc,make phpinsights,make lint-markdown - Fix issues:
make ecs-fix
Before Committing ⇩
Always run these commands before committing:
make ecs-fix # Auto-fix code style
make phpcs # PHP CodeSniffer
make ecs # EasyCodingStandard check
make phplint # PHPLint
make php-parallel-lint # Parallel lint
make phpstan # Static analysis
make psalm # Type checking
make phploc # Project metrics summary used by CI
make phpinsights # Quality thresholds check
make check-security # Dependency vulnerability check
make lint-markdown # Markdown/documentation linting
make run-tests # Run all testsTesting ⇩
Test Structure ⇩
tests/E2E/- End-to-end API teststests/Functional/- Functional tests with databasetests/Integration/- Integration tests for componentstests/Unit/- Unit tests for isolated componentstests/Utils/- Testing utilities and helperstests/DataFixtures/- Test data fixtures
Running Tests ⇩
# All tests (single thread)
make run-tests
# Mutation testing
make infectionTest Environment ⇩
- Uses separate test database
- Environment:
APP_ENV=test - Configuration:
phpunit.xml.dist - Fixtures loaded via
tests/DataFixtures/
Security ⇩
For the complete security policy, vulnerability reporting procedures, and
authentication details, see doc/SECURITY.md.
Authentication ⇩
- JWT Tokens: Using Lexik JWT Authentication Bundle
- API Keys: Managed via
api-key:managementconsole command - User Management: Available via
user:managementconsole command
Key Security Files ⇩
config/packages/security.yaml- Security configurationconfig/jwt/- JWT key storage (generated viamake generate-jwt-keys)secrets/- Application secrets storage
Security Best Practices ⇩
- Never commit
.env.localor JWT keys to version control - Use proper user roles and permissions
- Validate all input data with Symfony validation
- Use DTOs to control data exposure
- Run security checks:
make check-security
Configuration ⇩
Environment Files ⇩
.env- Default configuration (committed).env.local- Local overrides (ignored by git)APPLICATION_CONFIG- Path to JSON config file (default:secrets/application.json)
Key Configuration Files ⇩
config/services.yaml- Service configurationconfig/packages/- Bundle configurationsconfig/routes/- Route definitionssecrets/application.json- Application-specific configuration
View Current Configuration ⇩
Use make configuration to view current application configuration.
Documentation Structure ⇩
README.md- Project overview and installationCLAUDE.md- This file - long-form AI assistant context.github/copilot-instructions.md- Short operational rules for AI assistantsdoc/AI_RULES.md- AI policy maintenance and CI strategy guidancedoc/README.md- Documentation indexdoc/COMMANDS.md- Complete command reference (Makefile + Console)doc/DEVELOPMENT.md- Development best practices and workflowdoc/TESTING.md- Testing strategies and guidelinesdoc/CONCEPTS_AND_FEATURES.md- Architecture concepts and featuresdoc/CUSTOM_CONFIGURATION.md- Configuration managementdoc/PHPSTORM.md- PhpStorm IDE setupdoc/XDEBUG.md- Debugging setup and usagedoc/INSTALLATION_WITHOUT_DOCKER.md- Non-Docker installationdoc/SPEED_UP_DOCKER_COMPOSE.md- Performance optimizationdoc/USAGE_CHECKLIST.md- Pre-deployment checklist
Practical Guidance for AI Assistants ⇩
When making changes in this repository:
- Use the resource-based REST architecture; keep controllers thin.
- Follow existing Doctrine entity, repository, and migration patterns.
- Use DTOs for API input and output; do not expose entities directly.
- Use the AutoMapper for entity-to-DTO and DTO-to-entity mapping.
- Keep classes in
src/Controller/as thin as possible and delegate business logic to resources/services. - For custom controllers in
src/Controller/, prefer the__invokepattern (one controller class per endpoint). - Treat trait-based controllers in
src/Rest/as an exception to the__invokerule. - Declare
declare(strict_types=1);in every PHP file. - Keep changes compatible with PHPStan (max level) and Psalm.
- Write tests for new functionality and run the test suite before committing.
- Prefer the smallest change that fully solves the task.
- Avoid unrelated refactors unless explicitly required.
- Before commit, run the full static-analyzer suite used by CI
(
make phpcs,make ecs,make phplint,make php-parallel-lint,make psalm,make phpstan,make phploc,make phpinsights,make lint-markdown) inside the runningphpcontainer or IDE Dev Container, then run tests. - Use the
phpcontainer (symfony-backend-php-fpm) as the default command target and start it withmake start/make daemonwhen needed. - For markdown/documentation checks that require Node.js tooling, use
containerized
nvm+npxinstead of host-level installs. - Do not create commits unless the developer explicitly asks for a commit.
- After completing a task, provide a short change summary with touched files and validation steps that were run (or intentionally skipped).
- If requirements are ambiguous or incomplete, ask the developer for clarification before implementation.
- Do not assume hidden requirements or acceptance criteria; confirm uncertain behavior explicitly.
- Ask for explicit approval before making non-trivial API, database, security, or architecture decisions.
- Update relevant documentation when code changes affect behavior, architecture, workflow steps, commands, or review expectations.
- In the handoff summary, propose commit message(s) per logical change using
the repository pattern
Type(scope): short description(for exampleChore(ops): update AI documentation rules). - For Markdown documentation changes, follow
README.mdas formatting baseline (main title, anchors, table of contents, back-to-top links, back-to-previous footer links, and*list markers).
Documentation drift ⇩
This file is long-form context, not the only rules source. Keep it aligned with:
.github/copilot-instructions.mddoc/AI_RULES.md.github/pull_request_template.md- actual repository scripts and CI workflows
This document is maintained for AI assistants and contributors who need a high-level map of the project's architecture, workflow, and repository conventions.