Home

PSR1

PSR-1, or PHP Standards Recommendation 1, Basic Coding Standard, is a PHP-FIG standard that defines a minimal set of rules intended to improve interoperability of PHP code across projects. It focuses on basic file structure, encoding, and namespace usage rather than on stylistic details. The standard is designed to be lightweight and to complement more prescriptive standards such as PSR-2 (Coding Style Guide) and PSR-4 (Autoloading).

Key points include that files should use UTF-8 encoding without BOM; PHP code should be contained in

Impact and usage: PSR-1 has been widely adopted as a baseline in PHP frameworks and libraries, often

History: The PHP Framework Interop Group (PHP-FIG) published PSR-1 as part of a family of standards to

PHP
tags,
with
the
use
of
short
open
tags
discouraged;
and
if
a
file
declares
any
classes,
interfaces,
functions,
or
constants,
it
should
declare
a
namespace,
with
code
in
the
global
namespace
avoided
where
possible.
PSR-1
also
encourages
code
to
be
organized
in
a
way
that
supports
autoloading,
making
it
easier
for
autoloaders
to
locate
classes
by
their
fully
qualified
names.
referenced
in
coding
guidelines
and
continuous
integration
checks
to
ensure
cross-project
compatibility.
promote
interoperability
among
PHP
projects.
It
is
intended
to
be
stable
and
to
evolve
as
the
ecosystem
grows.