What Are PSR Standards in PHP?
PSRs (PHP Standard Recommendations) are community-agreed coding and interoperability standards published by the PHP-FIG (Framework Interoperability Group), c...
Published November 22, 2026
PSRs (PHP Standards Recommendations) are community standards from the PHP-FIG that make PHP libraries interoperable, covering coding style, autoloading, logging, HTTP messages and more. PSR-1, PSR-12 and PSR-4 are the ones every PHP developer meets first.
The concept
PSR-1/PSR-12 define coding style. PSR-4 defines namespace-to-folder autoloading used by Composer. PSR-3 standardises logging, PSR-7 and PSR-15 HTTP messages and middleware, PSR-11 containers.
Following them means libraries and frameworks can work together without glue code.
The ones you meet
Practical examples
PSR-4 in composer.json
{ "autoload": { "psr-4": { "App\\": "src/" } } }PSR-3 logger
use Psr\Log\LoggerInterface;
class Mailer { function __construct(private LoggerInterface $log) {} }Check style with PHP_CodeSniffer
vendor/bin/phpcs --standard=PSR12 src
vendor/bin/phpcbf --standard=PSR12 srcCommon mistakes
- Namespace/folder mismatch breaking PSR-4.
- Mixing styles in a codebase.
- Depending on a concrete logger instead of PSR-3.
Key takeaways
- Shared standards for PHP.
- PSR-4 + PSR-12 are essential.
- Type-hint PSR interfaces.
FAQ
Who defines PSRs?
The PHP Framework Interop Group.
Is PSR-2 current?
PSR-12 replaced it.