PHP的PSR (PSR 称为PHP Standard Recommendations)

PSR参考网址:http://www.php-fig.org/psr

在PHP中,有5个编码标准分类:
①、PSR-0 : Autoloading Standard , which goal is to make the use of Namespaces easier,
in order to convert a namespace into a file path.
②、PSR-1:Basic Coding Standard , basically, standards 😃
③、PSR-2:Coding Style Guide, where to put braces, how to write a class, etc.
④、PSR-3:Logger Interface , how to write a standard logger
⑤、PSR-4:Improved Autoloading , to resolve more Namespaces into paths。

PSR-4 autoloader
PSR-4 规范
①、The term "class" refers to classes,interfaces,traits, and other similar structures.
②、A fully qualified class names has the following form:

\<NamespaceName>(\<SubNamespaceNames>)*\<ClassName>

一、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 .php.
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.