Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 1.83 KB

standards.md

File metadata and controls

40 lines (31 loc) · 1.83 KB
title updated permalink
How to Write Standardized PHP Code?
October 9, 2016
/faq/coding-standards/

For PHP, there are many standards and coding style recommendations that you should look into when writing code. It simplifies collaboration on code and makes it more readable once you get used to a particular style.

One of the most adopted standards recommendations in PHP is PHP FIG, which recommends coding style via two of its PSRs (PHP Standard Recommendation):

  • PSR-1 - Basic Coding Standard
  • PSR-2 - Coding Style Guide

Many open source projects also extend the above PSRs with their own coding style guides, for example:

Many advanced PHP IDEs and editors also offer code refactoring via plugins and extensions. With predefined common coding styles such as PSR-1 and PSR-2, with refactoring code, automatic code generation, autocomplete and similar things, consistently writing standardized PHP code can be done with ease.

The more you write code, the more you will understand the importance in using common style guides. Especially when working with source code control (eg, Git, coworkers), or just to be consistent in general.

See Also