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

PSR-0Autoloading StandardIt describes the mandatory requirements that must be adhered to for autoloader interoperabilityDeprecated and substituted by PSR-4
PSR-1Basic Coding StandardIt comprises what should be considered the standard coding elements that are required to ensure a high level of technical interoperability between shared PHP codeAccepted
PSR-2Coding Style GuideIt 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 codeDeprecated
PSR-3Logger Interface It describes a common interface for logging librariesAccepted
PSR-4Autoloading StandardIt 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 specificationAccepted
PSR-5PHPDoc StandardThe 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 predecessorDraft
PSR-6Caching InterfaceThe 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 developmentAccepted
PSR-7HTTP Message InterfaceIt 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 3986Accepted
PSR-8Huggable InterfaceIt 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 projectsAbandoned
PSR-9Security DisclosureIt gives project leads a clearly defined approach to enabling end users to discover security disclosures using a clearly defined structured format for these disclosuresAdandoned
PSR-10Security AdvisoriesIt gives researchers, project leads, upstream project leads and end users a defined and structured process for disclosing security vulnerabilitiesAbandoned
PSR-11Container InterfaceIt 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-12Extended Coding Style GuideIt extends, expands and replaces PSR-2, the coding style guide and requires adherence to PSR-1, the basic coding standardAccepted
PSR-13Hypermedia LinksIt describes common interfaces for representing a hypermedia linkAccepted
PSR-14Event ManagerIt describes common interfaces for dispatching and handling eventsAccepted
PSR-15HTTP Server Request HandlersIt describes common interfaces for HTTP server request handlers and HTTP server middleware components that use HTTP messagesAccepted
PSR-16Simple CacheIt describes a simple yet extensible interface for a cache item and a cache driverAccepted
PSR-17HTTP FactoriesIt describes a common standard for factories that create PSR-7 compliant HTTP objectsAccepted
PSR-18HTTP ClientIt describes a common interface for sending HTTP requests and receiving HTTP responsesAccepted
PSR-19PHPDoc tagsIt provides a complete catalog of tags in the PHPDoc standardDraft
PSR-20ClockIt provides a standard way of accessing the clock – allowing interopability during testing, when testing behavior that has timing based side effectsAccepted
PSR-22Application TracingTBD.Draft

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

İlgili Yazılar