PSR-7 accepted - here are some resources about it

Last night, PSR-7 was officially accepted. We knew it was going to be for quite a while - but now it’s finally official. What is PSR-7, you may wonder?

If you’re not familiar with the PHP-FIG, it’s the PHP Framework Interoperability Group - a gathering of representatives from influential PHP projects working together to make the PHP landscape a little bit more streamlined, predictable, and structured by providing rules, standards and best practices. While it is by no means obligatory to follow their teachings, adhering to the rules helps not only you write reusable and easily refactorable code, but also assists others in jumping into your project later on and landing on their feet. Most of their recommendations are even available in e-book format, in one way or another.

The first of these PSRs (PHP Standard Recommendation) was an autoloading standard which allowed us to autoload classes in our projects interchangeably by splitting up a class’ namespace or name into file path segments and using those to find the file within the project’s folder. Here is an older post talking about it, if you’re curious. PSR-0 was eventually replaced by PSR-4, and the difference is explained in this post. PSR-1 and PSR-2 were coding standards, recommendations on how to write code to make it instantly readable and understandable by everyone, while PSR-3 was a logging interface, dictating a common approach to writing logging software. A decent overview is in this post. If we just got PSR-7 though, where are PSR-5 and PSR-6? Well, the numbers mean little to nothing - a higher one can come to fruition much sooner than the lower one, as Phil Sturgeon explains it.

So, what is PSR-7? PSR-7 is a common approach to writting HTTP messages. It defines interfaces on which to build Response and Request messages, along with all other HTTP communication - paving the way for truly uniform middleware design in future frameworks and other PHP libraries. We’ll have a more in depth look at PSR-7 and its use in an upcoming article, but for now, see the resources we’ve compiled here:

How do you feel about PSR-7? Is it a much needed update to the PHP environment, or a curse? Do you agree with Evert in his listing of the downsides?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.