PHP Standards Recommendation (PSR)
Overview
PSRs are coding and interoperability standards published by the PHP-FIG for PHP projects and libraries.
It matters because PSRs help PHP ecosystems work together more predictably across packages, frameworks, and teams.
What PSRs Are For
PSRs are meant to create common expectations.
They often cover:
- coding style
- autoloading
- interfaces
- HTTP message behavior
- logging and interoperability contracts
That makes PSRs especially useful where multiple packages and teams need to cooperate.
Why PSRs Matter
PSRs matter because shared standards reduce friction in the PHP ecosystem.
They help teams:
- write more interoperable libraries
- align code style
- understand common package expectations
- reduce framework-specific assumptions
This is one reason PSRs are referenced so often in modern PHP work.
PSR vs Framework Convention
PSRs and framework conventions are related but not the same.
- A framework convention may only matter inside one ecosystem.
- A PSR is meant to support broader interoperability across PHP projects.
That distinction matters when teams are building reusable packages or moving between frameworks.
Practical Caveats
PSRs are useful, but they are not a replacement for judgment.
- Not every project needs every PSR.
- Standards do not automatically create good architecture.
- Some recommendations are more central in daily work than others.
- Teams still need consistent enforcement and understanding.
PSRs are strongest when they reduce ambiguity without becoming ceremony for its own sake.
Frequently Asked Questions
Are PSRs mandatory in PHP?
No. They are recommendations and standards for interoperability, not core language requirements.
Why is PSR-4 so common?
Because autoloading conventions affect package structure and compatibility across the ecosystem.
Is PSR-12 about architecture?
No. It is primarily a coding-style standard.
Resources
- PHP-FIG: PHP-FIG
- PHP-FIG: Accepted PSRs
- PHP-FIG: PSR-12 Extended Coding Style