Have you made sure that the code for your website or application meets industry standards in terms of code quality? Are you a digital manager or a web project manager ? Do you use web developers to develop your website or your web application ? Have you changed your development team? V ou have then surely seen a developer hair pulling by reading the code. They are often confronted with code that is difficult to understand , or even illegible in the worst case . Imagine reading a text riddled with mistakes, with syntax errors, punctuation misused …

You now understand the Ghana Phone Numbers List of developers who affect to code that does not respect the rules of the art coding ! Good practices exist in web development . They make it possible to avoid these difficulties and in particular to facilitate the reading of the code and the collaboration between the developers (or other people likely to have to put their hands in the code). The PSR s (or PHP Standard Recommendation ) are a set of standards , norms, specific to PHP programming .

The goal? Provide a common technical basis to improve PHP programming practices and allow interoperability of components to make frameworks work together. Do you want to know what these PSR correspond to ? We will get there! But let’s start by introducing you to the FIG , the working group that created PSRs. psr-standards-programming-php What is FIG , the Interop Group Framework ? FIG : who is behind this acronym?

Are You Starting A Web Project?


This is the PHP Framework Interop Group . It was initiated by 5 developers in 2009. Several other developers at the initiative of various projects have now joined the group. This is how they describe themselves: We are a group of established PHP projects whose goal is to talk about the commonalities between our projects and find ways to work better together. They do not pretend to present themselves as an example or referents in PHP programming.


Moreover, we are talking about ” recommendations ” and nothing obliges you to follow them. These recommendations are however appreciated by the PHP community and widely recognized . Remember, PHP is a language prog ramming ! A little doubt? Here is a little dico of the words and expressions of the Web developers . PSR in more detail I explained quickly above that this ‘ was a PSR. A little reminder: this is a programming standard (or “ good practice ” ) specific to PHP . The idea is to harmonize the development methods .

They can be grouped into 4 main categories: The automatic loading : PSR-4 The interfaces : PSR-3, 6-PSR, PSR-11 … HTTP or the management of HTTP messages : PSR-7, PSR-15 … And the coding styles : PSR-1, PSR-12. A good example being clearer than a thousand explanations, here is a presentation of the four most famous PSRs . The ‘re PSR-1 and PSR – 2 / PSR – 1 2: the basics You might as well start this presentation of PSRs with numbers 1 and 2 (or 12!

Do You Use Php Developers?

You will soon understand where I am coming from). I present them to you together because they are linked. They fixed nt the minimum coding conventions , the elements required to ensure interoperability between high-level shared PHP code . The PSR-1 shows the basic coding standards : Files should only use <? php and <? = . The code must use the long or short echo tags and must not use the other variant tags. PHP code should only use UTF-8 (the universal / international character encoding to avoid character display faults). Method names must be declared in camelCase (). …

In short, you understand that the general idea is to establish coding standards : which tag to use, how to declare such and such an element … and this in order to facilitate reading and understanding by all. An example in picture : psr-1 – constants “Class constants MUST be declared in uppercase with underscores” The PSR – 2 titled “ Coding Style Guide ” is certainly one of the best known. It was declared obsolete in 2019 and replaced by PSR – 12 “Extended Coding Style Guide” . Here are some excerpts: The software limit on the line length must be 120 characters.

Lines should be no more than 80 characters long or be split into multiple lines of up to 80 characters each. All reserved PHP keywords and types must be lowercase. Any closing brace should not be followed by a comment or statement on the same line. And many others ! In short, to keep it simple, it’s a bit like if you had to write a text and you were told “Do not write sentences of more than 10 words, write the last names in capitals, skip a line between two sentences. …

Leave a Reply

Your email address will not be published.