is the abbreviation of PHP Standard Recommendation. It should actually be called PSRs, which is a series of recommended standards: currently passed specifications include PSR-0 (Autoloading Standard), PSR-1 (Basic Coding Standard), PSR-2 (Coding Style Guide) ), PSR-3 (Logger Interface), PSR-4 (Improved Autoloading). It is not an official PHP standard, but a series of standards extracted from well-known PHP projects such as Zend and Symfony2. Currently, more and more community projects have joined as members and follow this standard.
PHP-FIG — PHP Framework Interoperability Group, is an organization that formulates PSRs development specifications. Its members are composed of many well-known PHP community projects. You can see the member list at the bottom of its official website homepage. These members develop specifications and implement them in their projects.
In fact, the content of each PSR specification is very concise and clear, which is much better than those specifications that span dozens of pages.
PSR-0 is the automatic class loading specification (original text: official website, GitHub). As of 2014-10-21, this specification is marked Deprecated and replaced by PSR-4. Its content is very concise.
Content:
PSR-1 is the basic coding standard (original text: official website, GitHub). Is the content concise, including the naming method of class files, class names, and class method names?
Content:
PSR-2 is the coding style standard (original text: official website, GitHub). The content is slightly more, but it is still relatively concise. It is based on PSR-1 and includes relevant provisions for indentation, length of each line of code, line breaks, method visibility declarations, spaces, and method body brace wrapping.
Standard content:
PSR-3 is the definition of application log class through interface (original text: official website, GitHub). The content is very simple, it is just an interface. Just quote the official sample code. Of course, in specific applications, as long as you follow this interface, you can definitely customize the corresponding implementation.
Basic content:
PSR-4 is an improved version of the automatic loading specification (original text: official website, GitHub). It is the successor to the PSR-0 specification. It is compatible with any other autoloading specification, including PSR-0.
Content:
The implementation of the autoloader must not throw any exceptions or cause errors of any level; nor should it return a value
Note: The specific specification content is compiled with reference to other Chinese translation versions.