ONLINE TESTS EDITING BOARD
RO
EN
×
▼ BROWSE ISSUES ▼
Issue 45

PSR Standards in the PHP World

Radu Murzea
PHP Developer
@Pentalog
PROGRAMMING

Correct ways to build a house, to manufacture screens of certain resolutions or fitted sizes for the clothes we wear, correct ways of measurement - these are all standards that are everywhere around us. In the case of PHP, the standards are represented by the PSR specifications. We want to invite standards into the world of PHP, so that we can better understand the ecosystem around the PHP language and its future evolution.

A little history.

Every programming language has standards and ways to solve problems that are considered best-practice in their world. Even PHP had something similar, but these standards were scattered in various corners of its community, with no recognizable entity that would centralize, govern and promote them.

In 2009 all this changed, because 5 PHP frameworks developers met at the php|tek 2009 conference in Chicago and decided to create a governing entity that would solve the problem of PHP standards once and for all. The group called itself PHP-FIG (PHP Framework Interoperability Group). Shortly after its birth, their first standard, called PSR-0, was published. This standard came as a result of the support for namespaces added by the newly launched 5.3 version of PHP; it standardized the way this new feature was used.

About PSR standards.

PSR stands for PHP Standard Recommendation. The way these standards work is very similarly to JSRs (Java Specification Request) from the Java world. They're numbered starting with 0 and contain a formal specification for a certain programming technique or a certain feature that can be implemented in PHP.

At the moment this article was written, there were 7 PSR standards, already published and used:

Some of the standards described above are not written from scratch, but instead are based on a few popular RFC references. Also, all PSR standards use the specifications of RFC-2119, which describes a common vocabulary to be used in formal technical specifications.

The working mechanisms of PHP-FIG are very similar to the ones used by the Java world for its JSR standards:

Over time, there have been multiple controversies regarding the group's objective nature and its role in the PHP world. While some concerns might be sound, we need to keep in mind an important aspect regarding this group and the standards it proposes: implementing them or using them is completely optional.

This implies that PSR standards share a lot of properties with design-patterns:

On top of all this, we have to remember the group's main goal: collaboration between frameworks (hence the group's name). Therefore, the standards they propose will tend to be related to features already present in most frameworks. The main idea and philosophy is to have an easy way to swap common libraries on which these frameworks depend.

Conclusion

Even though PHP-FIG is a controversial group that was founded a little too late, it still managed to impose itself as the absolute authority of PHP standards. The publishing of PSR standards by this group marked the beginning of a sustained maturity of the PHP ecosystem.

Sponsors

  • ntt data
  • 3PillarGlobal
  • Betfair
  • Telenav
  • Accenture
  • Siemens
  • Bosch
  • FlowTraders
  • MHP
  • BCR
  • Itiviti
  • Connatix
  • UIPatj
  • MicroFocus
  • Colors in projects