PHP之PSR

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.

转载于:https://www.cnblogs.com/2018-05-9-ygk/p/9516118.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值