The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.
This PSR describes a specification for autoloading classes from file paths. It is fully interoperable, and can be used in addition to any other autoloading specification, including PSR-0. This PSR also describes where to place files that will be autoloaded according to the specification.
The term “class” refers to classes, interfaces, traits, and other similar structures.
A fully qualified class name has the following form:
The fully qualified class name MUST have a top-level namespace name, also known as a “vendor namespace”.
The fully qualified class name MAY have one or more sub-namespace names.
The fully qualified class name MUST have a terminating class name.
Underscores have no special meaning in any portion of the fully qualified class name.
Alphabetic characters in the fully qualified class name MAY be any combination of lower case and upper case.
All class names MUST be referenced in a case-sensitive fashion.
When loading a file that corresponds to a fully qualified class name …
A contiguous series of one or more leading namespace and sub-namespace names, not including the leading namespace separator, in the fully qualified class name (a “namespace prefix”) corresponds to at least one “base directory”.
The contiguous sub-namespace names after the “namespace prefix” correspond to a subdirectory within a “base directory”, in which the namespace separators represent directory separators. The subdirectory name MUST match the case of the sub-namespace names.
The terminating class name corresponds to a file name ending in
The file name MUST match the case of the terminating class name.
Autoloader implementations MUST NOT throw exceptions, MUST NOT raise errors of any level, and SHOULD NOT return a value.
The table below shows the corresponding file path for a given fully qualified class name, namespace prefix, and base directory.
|Fully Qualified Class Name||Namespace Prefix||Base Directory||Resulting File Path|
For example implementations of autoloaders conforming to the specification, please see the examples file. Example implementations MUST NOT be regarded as part of the specification and MAY change at any time.