Includes composer.json and project-structure templates (src/ for library code, tests/ wired via autoload-dev, PSR-4 namespace mapping), and the core PER/PSR-1 file rules (4 spaces, LF endings, no closing ?>).
Do NOT use this skill for language syntax or feature questions — that is php-language-modern. Do NOT use it for Laravel-specific conventions, which live in the Laravel plugin.
PHP Standards (PSR / PER / Composer)
Agent Workflow (MANDATORY)
Before applying a standard, spawn 3 agents in parallel, one Agent call each with a name:
- fuse-ai-pilot:explore-codebase - Detect existing style config (
.php-cs-fixer.php, phpcs.xml), composer.json autoload
- fuse-ai-pilot:research-expert - Verify a PSR's current status on php-fig.org before recommending it
- mcp__context7__query-docs - Cross-check composer.json schema
After changes, run fuse-ai-pilot:sniper for validation.
Overview
| Concern |
Standard |
Notes |
| Autoloading |
PSR-4 |
Recommended; PSR-0 is deprecated |
| Coding style |
PER Coding Style 3.0 |
"Extends, expands and replaces PSR-12"; PSR-12 remains the Accepted PSR |
| Logging |
PSR-3 |
LoggerInterface |
| Caching |
PSR-6 / PSR-16 |
Pool vs Simple Cache |
| HTTP |
PSR-7 / 15 / 17 / 18 |
Message / Handlers / Factories / Client |
| DI container |
PSR-11 |
ContainerInterface |
| Events |
PSR-14 |
Event Dispatcher |
| Time |
PSR-20 |
ClockInterface — testable "now" |
Critical Rules
- PSR-4 for autoloading, never PSR-0 - PSR-0 and
target-dir are deprecated. See psr4-autoloading.md.
- PER Coding Style 3.0 is the current style spec - It supersedes PSR-12 in practice while requiring PSR-1. PSR-12 is still the officially Accepted PSR — document the nuance, don't pretend PSR-12 was withdrawn. See per-coding-style.md.
- Depend on PSR interfaces, not implementations - Type-hint
Psr\Log\LoggerInterface, not a concrete logger.
- 4 spaces, no tabs; LF line endings; omit closing
?> - Core PER/PSR-1 file rules.
src/ for library code, tests/ for tests - Wire tests/ via autoload-dev, never autoload.
Architecture
my-package/
├── composer.json # PSR-4 autoload + autoload-dev + scripts
├── src/ # Namespace root (Vendor\Package\)
│ └── Service.php
├── tests/ # PSR-4 dev namespace (Vendor\Package\Tests\)
│ └── ServiceTest.php
└── bin/ # CLI entry points (composer "bin")
→ See project-structure.md for the full layout
Reference Guide
Concepts
| Topic |
Reference |
When to Consult |
| PER Coding Style |
per-coding-style.md |
Formatting rules, PER vs PSR-12 |
| PSR catalog |
psr-catalog.md |
Which PSR to depend on / avoid |
| PSR-4 autoloading |
psr4-autoloading.md |
Namespace-to-path mapping |
Templates
| Template |
When to Use |
| composer-json.md |
Starting or modernizing a package |
| project-structure.md |
Laying out directories |
Best Practices
DO
- Use PSR-4 with
src/ mapped to the vendor namespace
- Follow PER Coding Style 3.0 (run php-cs-fixer with the
@PER-CS ruleset)
- Depend on PSR interface packages (
psr/log, psr/http-message, …)
- Put test-only classes under
autoload-dev
DON'T
- Use PSR-0 autoloading or
target-dir (deprecated)
- Claim PER "replaced" PSR-12 as the official standard — PSR-12 is still Accepted
- Depend on PSR-2/PSR-0 (deprecated) or PSR-8/9/10 (abandoned)
- Hardcode a concrete logger/cache when a PSR interface exists
1---2name: php-standards3description: Use when setting up PHP-package autoloading, coding style, or PSR interfaces — PSR-4, PER Coding Style 3.0, composer.json. Do NOT use for syntax or Laravel.4---56<objective>7Covers the standards that shape a framework-agnostic PHP package: PSR-4 autoloading (and why PSR-0 is deprecated), PER Coding Style 3.0 versus the still-Accepted PSR-12, and the current PSR catalog to depend on for logging (PSR-3), caching (PSR-6/16), HTTP (PSR-7/15/17/18), DI containers (PSR-11), events (PSR-14), and time (PSR-20).89Includes composer.json and project-structure templates (src/ for library code, tests/ wired via autoload-dev, PSR-4 namespace mapping), and the core PER/PSR-1 file rules (4 spaces, LF endings, no closing ?>).1011Do NOT use this skill for language syntax or feature questions — that is php-language-modern. Do NOT use it for Laravel-specific conventions, which live in the Laravel plugin.12</objective>1314# PHP Standards (PSR / PER / Composer)1516## Agent Workflow (MANDATORY)1718Before applying a standard, spawn 3 agents in parallel, one `Agent` call each with a `name`:19201. **fuse-ai-pilot:explore-codebase** - Detect existing style config (`.php-cs-fixer.php`, `phpcs.xml`), `composer.json` autoload212. **fuse-ai-pilot:research-expert** - Verify a PSR's current status on php-fig.org before recommending it223. **mcp__context7__query-docs** - Cross-check composer.json schema2324After changes, run **fuse-ai-pilot:sniper** for validation.2526---2728## Overview2930| Concern | Standard | Notes |31|---------|----------|-------|32| **Autoloading** | PSR-4 | Recommended; PSR-0 is deprecated |33| **Coding style** | PER Coding Style 3.0 | "Extends, expands and replaces PSR-12"; PSR-12 remains the *Accepted* PSR |34| **Logging** | PSR-3 | `LoggerInterface` |35| **Caching** | PSR-6 / PSR-16 | Pool vs Simple Cache |36| **HTTP** | PSR-7 / 15 / 17 / 18 | Message / Handlers / Factories / Client |37| **DI container** | PSR-11 | `ContainerInterface` |38| **Events** | PSR-14 | Event Dispatcher |39| **Time** | PSR-20 | `ClockInterface` — testable "now" |4041---4243## Critical Rules44451. **PSR-4 for autoloading, never PSR-0** - PSR-0 and `target-dir` are deprecated. See [psr4-autoloading.md](references/psr4-autoloading.md).462. **PER Coding Style 3.0 is the current style spec** - It supersedes PSR-12 in practice while requiring PSR-1. PSR-12 is still the officially *Accepted* PSR — document the nuance, don't pretend PSR-12 was withdrawn. See [per-coding-style.md](references/per-coding-style.md).473. **Depend on PSR interfaces, not implementations** - Type-hint `Psr\Log\LoggerInterface`, not a concrete logger.484. **4 spaces, no tabs; LF line endings; omit closing `?>`** - Core PER/PSR-1 file rules.495. **`src/` for library code, `tests/` for tests** - Wire `tests/` via `autoload-dev`, never `autoload`.5051---5253## Architecture5455```56my-package/57├── composer.json # PSR-4 autoload + autoload-dev + scripts58├── src/ # Namespace root (Vendor\Package\)59│ └── Service.php60├── tests/ # PSR-4 dev namespace (Vendor\Package\Tests\)61│ └── ServiceTest.php62└── bin/ # CLI entry points (composer "bin")63```6465→ See [project-structure.md](references/templates/project-structure.md) for the full layout6667---6869## Reference Guide7071### Concepts7273| Topic | Reference | When to Consult |74|-------|-----------|-----------------|75| **PER Coding Style** | [per-coding-style.md](references/per-coding-style.md) | Formatting rules, PER vs PSR-12 |76| **PSR catalog** | [psr-catalog.md](references/psr-catalog.md) | Which PSR to depend on / avoid |77| **PSR-4 autoloading** | [psr4-autoloading.md](references/psr4-autoloading.md) | Namespace-to-path mapping |7879### Templates8081| Template | When to Use |82|----------|-------------|83| [composer-json.md](references/templates/composer-json.md) | Starting or modernizing a package |84| [project-structure.md](references/templates/project-structure.md) | Laying out directories |8586---8788## Best Practices8990### DO91- Use PSR-4 with `src/` mapped to the vendor namespace92- Follow PER Coding Style 3.0 (run php-cs-fixer with the `@PER-CS` ruleset)93- Depend on PSR interface packages (`psr/log`, `psr/http-message`, …)94- Put test-only classes under `autoload-dev`9596### DON'T97- Use PSR-0 autoloading or `target-dir` (deprecated)98- Claim PER "replaced" PSR-12 as the official standard — PSR-12 is still *Accepted*99- Depend on PSR-2/PSR-0 (deprecated) or PSR-8/9/10 (abandoned)100- Hardcode a concrete logger/cache when a PSR interface exists