What are PHP PSR Standards?

php psr standarts

PHP, a powerful programming language, hosts a broad user base and various projects. However, challenges may arise in terms of interoperability and code consistency among different frameworks, libraries, and projects. This is where the PHP Framework Interop Group (PHP-FIG) steps in with PHP PSR Stndards, PSR (PHP Standard Recommendations) to address these issues and unify the PHP ecosystem.

What is PSR?

PSR stands for PHP Standard Recommendations, proposed by PHP-FIG. These standards are created to ensure the compatibility of PHP applications and libraries. PSR documents can cover various topics but often include standards ranging from coding styles to autoloader standards.

Importance of PSRs

  1. Interoperability: PSRs enhance interoperability among different PHP frameworks and libraries, allowing developers to transition seamlessly between various projects.

  2. Preventing Code Inconsistency: PSRs set standards to ensure code consistency in specific areas. This enables developers to write more readable and maintainable code.

  3. Community Consensus: PSRs establish a consensus among PHP developers, showcasing that setting a standard is a democratic process. This helps in the adoption and widespread use of standards accepted by the community.

PHP Standard Recommendations serve as a crucial tool in unifying the PHP ecosystem and providing developers with a more consistent experience. PSRs set standards in areas such as interoperability, code consistency, and community consensus, empowering the PHP community. Developers can refer to PSR documents to write more consistent and compatible code in their projects, ultimately enhancing the overall quality of the PHP ecosystem.

PHP PSR Standards

Number Name Descrıptıon Status
PSR-0 Autoloading Standard It describes the mandatory requirements that must be adhered to for autoloader interoperability Deprecated and substituted by PSR-4
PSR-1 Basic Coding Standard It comprises what should be considered the standard coding elements that are required to ensure a high level of technical interoperability between shared PHP code Accepted
PSR-2 Coding Style Guide It considers PSR-1 and it is intended to reduce cognitive friction when scanning code from different authors. It does so by enumerating a shared set of rules and expectations about how to format PHP code Deprecated
PSR-3 Logger Interface It describes a common interface for logging libraries Accepted
PSR-4 Autoloading Standard It 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 auto loaded according to the specification Accepted
PSR-5 PHPDoc Standard The main purpose of this PSR is to provide a complete and formal definition of the PHPDoc standard. This PSR deviates from its predecessor, the de facto PHPDoc Standard associated with phpDocumentor 1.x, to provide support for newer features in the PHP language and to address some of the shortcomings of its predecessor Draft
PSR-6 Caching Interface The goal of this PSR is to allow developers to create cache-aware libraries that can be integrated into existing frameworks and systems without the need for custom development Accepted
PSR-7 HTTP Message Interface It describes common interfaces for representing HTTP messages as described in RFC 7230 and RFC 7231, and URIs for use with HTTP messages as described in RFC 3986 Accepted
PSR-8 Huggable Interface It establishes a common way for objects to express mutual appreciation and support by hugging. This allows objects to support each other in a constructive fashion, furthering cooperation between different PHP projects Abandoned
PSR-9 Security Disclosure It gives project leads a clearly defined approach to enabling end users to discover security disclosures using a clearly defined structured format for these disclosures Adandoned
PSR-10 Security Advisories It gives researchers, project leads, upstream project leads and end users a defined and structured process for disclosing security vulnerabilities Abandoned
PSR-11 Container Interface It describes a common interface for dependency injection containers. The goal is to standardize how frameworks and libraries make use of a container to obtain objects and parameters (called entries in the rest of this document) Accepted
PSR-12 Extended Coding Style Guide It extends, expands and replaces PSR-2, the coding style guide and requires adherence to PSR-1, the basic coding standard Accepted
PSR-13 Hypermedia Links It describes common interfaces for representing a hypermedia link Accepted
PSR-14 Event Manager It describes common interfaces for dispatching and handling events Accepted
PSR-15 HTTP Server Request Handlers It describes common interfaces for HTTP server request handlers and HTTP server middleware components that use HTTP messages Accepted
PSR-16 Simple Cache It describes a simple yet extensible interface for a cache item and a cache driver Accepted
PSR-17 HTTP Factories It describes a common standard for factories that create PSR-7 compliant HTTP objects Accepted
PSR-18 HTTP Client It describes a common interface for sending HTTP requests and receiving HTTP responses Accepted
PSR-19 PHPDoc tags It provides a complete catalog of tags in the PHPDoc standard Draft
PSR-20 Clock It provides a standard way of accessing the clock – allowing interopability during testing, when testing behavior that has timing based side effects Accepted
PSR-21 Internationalization TBD. Draft
PSR-22 Application Tracing TBD. Draft

Eğitimin, Eğlencenin ve Haberin Sitesi TEKNOKODİ

İlgili Yazılar