Symfony Coding Practices
Application skill for Symfony official coding standards ingest (awesome-guidelines). Generic PHP: php-coding-practices. PSR layout overlap shared; Symfony adds Yoda, service ids, and exception prose rules.
Core Principle
Symfony PHP reads uniformly, PSR-12 via PHP CS Fixer, Yoda identical compares, strict naming matrix, FQCN service ids, and formatted exception/deprecation messages with MIT headers.
When to Use / NOT
- Symfony components, bundles, apps, and Symfony-style OSS libraries.
- Configuring PHP CS Fixer with Symfony rule set.
- PR review on Symfony contribution or internal bundle.
NOT when:
- Generic PHP without Symfony conventions,
php-coding-practices.
- Laravel/WordPress-specific style, stack capsules in
skills/*-foundation.
- Runtime Symfony architecture (DI tags, events), framework docs/foundation.
Workflow
- Structure, spacing, Yoda, control flow, class order (
symfony-style-structure-control.md).
- Naming/services, case matrix, FQCN ids (
symfony-style-naming-services.md).
- PHPDoc/errors, docs, exceptions, license (
symfony-style-phpdoc-exceptions.md).
- Verify, PHP CS Fixer + tests (
symfony-style-verify.md).
Red Flags
- php-cs-fixer diff on changed PHP
- Loose
== without documented reason
- Literal on RHS in comparisons (
$x === 'foo' not Yoda)
- else/elseif after return/throw branch
- break after return in switch case
- Spaces inside array offset brackets
- Missing use import for namespaced class
- camelCase config parameter or route name
- Twig template not snake_case
- Abstract class without Abstract prefix (new code)
- Primary service id not FQCN
- Backticks in exception message
- Exception message missing terminal period
$obj::class in exception string (use get_debug_type)
- One-line PHPDoc block
- Missing MIT license header before namespace
- void return type on PHPUnit test method
Verification
vendor/bin/php-cs-fixer fix -v --dry-run on changed paths
- PHPUnit on touched components
- License header on new files
- debug:container for new service ids
- Capsule checklist on exceptions and Yoda compares
References
awesome-guidelines/references/symfony-style-learning-note.md
awesome-guidelines/references/symfony-style-structure-control.md
awesome-guidelines/references/symfony-style-naming-services.md
awesome-guidelines/references/symfony-style-phpdoc-exceptions.md
awesome-guidelines/references/symfony-style-verify.md
Related skills
php-coding-practices, PSR-12, strict_types, DI baseline
api-design-practices, HTTP API adjacent to Symfony routes
webappsec-coding-practices, web security on Symfony apps
1---2name: symfony-coding-practices3description: Use when authoring or reviewing Symfony PHP, PHP CS Fixer, Yoda identical compares, naming matrix, FQCN services, PHPDoc rules, sprintf exceptions, and MIT license headers.4---56# Symfony Coding Practices78Application skill for Symfony official coding standards ingest (`awesome-guidelines`). Generic PHP: `php-coding-practices`. PSR layout overlap shared; Symfony adds Yoda, service ids, and exception prose rules.910## Core Principle1112Symfony PHP reads uniformly, **PSR-12 via PHP CS Fixer**, **Yoda identical compares**, **strict naming matrix**, **FQCN service ids**, and **formatted exception/deprecation messages** with MIT headers.1314## When to Use / NOT1516- Symfony components, bundles, apps, and Symfony-style OSS libraries.17- Configuring PHP CS Fixer with Symfony rule set.18- PR review on Symfony contribution or internal bundle.1920**NOT when:**2122- Generic PHP without Symfony conventions, `php-coding-practices`.23- Laravel/WordPress-specific style, stack capsules in `skills/*-foundation`.24- Runtime Symfony architecture (DI tags, events), framework docs/foundation.2526## Workflow27281. **Structure**, spacing, Yoda, control flow, class order (`symfony-style-structure-control.md`).292. **Naming/services**, case matrix, FQCN ids (`symfony-style-naming-services.md`).303. **PHPDoc/errors**, docs, exceptions, license (`symfony-style-phpdoc-exceptions.md`).314. **Verify**, PHP CS Fixer + tests (`symfony-style-verify.md`).3233## Red Flags3435- php-cs-fixer diff on changed PHP36- Loose `==` without documented reason37- Literal on RHS in comparisons (`$x === 'foo'` not Yoda)38- else/elseif after return/throw branch39- break after return in switch case40- Spaces inside array offset brackets41- Missing use import for namespaced class42- camelCase config parameter or route name43- Twig template not snake_case44- Abstract class without Abstract prefix (new code)45- Primary service id not FQCN46- Backticks in exception message47- Exception message missing terminal period48- `$obj::class` in exception string (use get_debug_type)49- One-line PHPDoc block50- Missing MIT license header before namespace51- void return type on PHPUnit test method5253## Verification5455- `vendor/bin/php-cs-fixer fix -v --dry-run` on changed paths56- PHPUnit on touched components57- License header on new files58- debug:container for new service ids59- Capsule checklist on exceptions and Yoda compares606162## References6364- `awesome-guidelines/references/symfony-style-learning-note.md`65- `awesome-guidelines/references/symfony-style-structure-control.md`66- `awesome-guidelines/references/symfony-style-naming-services.md`67- `awesome-guidelines/references/symfony-style-phpdoc-exceptions.md`68- `awesome-guidelines/references/symfony-style-verify.md`6970## Related skills7172- `php-coding-practices`, PSR-12, strict_types, DI baseline73- `api-design-practices`, HTTP API adjacent to Symfony routes74- `webappsec-coding-practices`, web security on Symfony apps