Standardization is the one of most important things while we’re coding. It gives us readability, easy understanding, and more. PSR is about PHP. The PHP Standards Recommendations which developed by the community. This means, while you’re learning PHP you should learn PSRs too.
Most used PHP Frameworks (Laravel, Symfony, etc.) are developed with these standards. If you learn them together you’ll understand the framework architectures easier.
Why Did They Build These Standards?
If there is no standardization everything goes more complicated. You can think about standardization like finding a common way. If we can create a common way to do things we can handle them much easier.
In software building, this is more important to save time while building things. If there was no standardization or standardized architecture we need to educate all developers before they start to work. With these standardizations, we can create documentation for these standards or architectures. So, everyone can learn them easily.
When something went wrong we would not find where to look for bugs or errors. With these standardizations, we can prevent or solve problems easier.
Standardization is a good idea for other areas too. An example, if you use any metro service in any country you can not be lost. Because all signs, all redirections are the same as other places in the world. So you can use the metro in London or Istanbul with the same redirections. (The idea is similarity percent not totally equality.) And many more examples would be here.
How Did They Build These Standards?
The recommendation needs experience. These all standards come from the community’s experiences. While you’re adapting these standards this means you’re using the community’s experience. Think about how valuable is this.
Syntaxes may different per language. Most of the time standardization is about syntax but the algorithmic standardizations are different than coding standards. Because they are not about syntax so you can use them in other languages too.
The recommendations have levels. The levels of them are:
- MUST NOT
- SHALL NOT
- SHOULD NOT
How Many PSR Published?
There are 12 accepted PSR versions now. 3 drafts, 3 abandoned and 2 deprecated. As you can see they are named by their subjects. They also got really valuable recommendations. You should read and understand them.
The Accepted Standards
- 1: Basic Coding Standard
- 3: Logger Interface
- 4: Autoloading Standard
- 6: Caching Interface
- 7: HTTP Message Interface
- 11: Container Interface
- 12: Extended Coding Style Guide
- 13: Hypermedia Links
- 14: Event Dispatcher
- 15: HTTP Handlers
- 16: Simple Cache
- 17: HTTP Factories
- 18: HTTP Client
- 5: PHPDoc Standard
- 19: PHPDoc tags
- 20: Clock
- 8: Huggable Interface
- 9: Security Advisories
- 10: Security Reporting Process
- 0: Autoloading Standard
- 2: Coding Style Guide
All PSRs are published at https://www.php-fig.org/. You can also track them there.
Thanks for reading. See you in the next post!
Hello I’m İlyas Özkurt. I am a software developer who has been working on websites for 10 years. My first studies in this field were during my high school years. Now I work as a software developer at 6harf and am responsible for all web projects there.