What are the contents of the PSR Series specification for PHP, what are the PHPPSR specifications _php Tutorials

Source: Internet
Author: User
Tags php framework

What are the contents of the PSR Series specifications of PHP, what are the PHPPSR specifications?


Psr

PHP Standard recommendation shorthand, it should be called PSRs, that is, the series of recommended standards: the current adoption of the specification has PSR-0 (autoloading), PSR-1 (Basic Coding) , PSR-2 (Coding Style Guide), PSR-3 (Logger Interface), PSR-4 (improved autoloading). It is not the official PHP standard, but a series of standards extracted from well-known PHP projects such as Zend, Symfony2, and now more and more community projects are joining members and following that standard.

php-fig-php Framework Interoperability Group is an organization that formulates PSRS development specifications, and its members are made up of many well-known PHP community projects, and a list of members can be found at the bottom of their homepage. These members develop specifications and are implemented in their own projects.

In fact, the content of each PSR specification is very concise and clear, compared to those who move the dozens of-page specification, is really good too much.

PSR-0 (autoloading Standard)

PSR-0-Class Automatic Loading specification (original: official website, GitHub). From 2014-10-21 onwards, the specification was marked as Deprecatedand replaced by PSR-4. Its contents are very concise.

Content:

PSR-1 (Basic Coding Standard)

PSR-1 is the basic coding standard (original: website, GitHub). The content is also concise, including the class file, class name, class method name naming methods.

Content:

PSR-2 (Coding Style Guide)

PSR-2 is the coding style standard (original: official website, GitHub). Slightly more content, but still relatively concise, it is based on PSR-1, including indentation, each line of code length, line wrapping, method visibility declarations, spaces, and method body braces for wrapping the relevant provisions.

Standard content:

PSR-3 (Logger Interface)

PSR-3 is the definition of the pass-through interface to the Application log Class (original: Official website, GitHub). The content is simple, is an interface, the official sample code to reference it. Of course, in a specific application, as long as you follow this interface, you can certainly customize the corresponding implementation.

Basic content:

PSR-4 (improved autoloading)

PSR-4 is an improved version of the automatic Loading specification (original: official website, GitHub). It is the successor to the PSR-0 specification. It can be compatible with any other auto-loading specification, including PSR-0.

Content:

  • When you load a file from a fully qualified class name:
  • The implementation of the automatic loader cannot throw any exceptions, cannot raise any level of error, and should not return a value

  • Note: The specific specifications refer to other Chinese translation version collation.

    http://www.bkjia.com/PHPjc/947048.html www.bkjia.com true http://www.bkjia.com/PHPjc/947048.html techarticle PHP PSR Series specifications have what content, PHPPSR specification has what PSR is PHP standard recommendation shorthand, it actually should be called PSRs, that is, the series recommended standard: Currently passed the specification has PSR ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.