PSR-1 is a PHP Standards Recommendation created by the PHP-FIG (Framework Interop Group) that defines basic coding standards for PHP code style and structure to ensure interoperability between different PHP projects and frameworks. Its main purpose is to establish a consistent baseline for PHP code, making it easier to understand and collaborate on projects across the PHP ecosystem. PSR-1, also known as the Basic Coding Standard, includes several key guidelines:
File Formatting:
<?php
or <?=
tags.Namespace and Class Names:
StudlyCaps
(PascalCase).Constants, Properties, and Method Naming:
CONST_VALUE
).camelCase
.Autoloading:
include
or require
statements.PSR-1 is considered a foundational standard, and it works in tandem with PSR-2 and PSR-12, which define more detailed code formatting guidelines. Together, these standards help improve code readability and consistency across PHP projects.