PSR
4 August 2025 (Updated 4 August 2025)
On this page
What is PSR?
PSR stands for PHP Standards Recommendation and is a set of guidelines published by the PHP-FIG (PHP Framework Interop Group) to standardise things across PHP projects, especially libraries and frameworks.
What kind of standards does PSR define?
- Coding style
- PSR-1: Basic coding standards (e.g., class names must be
StudlyCaps
, files must use<?php
, etc). - PSR-12: Standards for indentation, spacing, etc.
- PSR-1: Basic coding standards (e.g., class names must be
- Autoloading
- PSR-4: Defines autoloading standards using namespaces and directory structures.
- PSR-0: The now deprecated autoloading standards.
- Containers & Services
- PSR-11: Defines standards for dependency injection containers (defines a common
ContainerInterface
).
- PSR-11: Defines standards for dependency injection containers (defines a common
- HTTP messaging
- PSR-7: HTTP message interfaces (defines
RequestInterface
,ResponseInterface
). - PSR-15: HTTP middleware interface (defines how middleware should be written).
- PSR-17: HTTP factory interfaces for creating PSR-7 compliant objects.
- PSR-7: HTTP message interfaces (defines
- Logging & Caching
- PSR-3 (GitHub repo): Logging interfaces (defines a
LoggerInterface
with particular levels likeinfo
,error
, etc). - PSR-6: Low-level, pool-based acching interface.
- PSR-16: Simplified caching interface (key-value style)
- PSR-3 (GitHub repo): Logging interfaces (defines a
Tagged:
PHP