Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of highly-regarded PHP style guides?

I've recently been shaking up my coding habits and have been toying with various approaches to coding style... things like using a space between method call parentheses and the parameters they contain, how to deal with multi-line array definitions and method calls, etc.

I'm wary of creating my personal flavor of everything, though, and want to skim through some well-regarded "authoritative" style guides. Which ones should I look at? I've had a hard time finding much other than the Zend guide.

like image 437
keithjgrant Avatar asked Sep 03 '10 17:09

keithjgrant


People also ask

Is PSR 2 deprecated?

Deprecated - As of 2019-08-10 PSR-2 has been marked as deprecated. PSR-12 is now recommended as an alternative. This guide extends and expands on PSR-1, the basic coding standard. The intent of this guide is to reduce cognitive friction when scanning code from different authors.

What is PSR return?

PSR is the point furthest from the airfield of departure that an aircraft can fly and still return to base within its safe endurance. (

What PSR-1?

PSR-1. Basic Coding Standard. It comprises what should be considered the standard coding elements that are required to ensure a high level of technical interoperability between shared PHP code.

What do you know about PHP coding Standards What standards have you used?

There are few guidelines which can be followed while coding in PHP. Indenting and Line Length − Use an indent of 4 spaces and don't use any tab because different computers use different setting for tab. It is recommended to keep lines at approximately 75-85 characters long for better code readability.


1 Answers

The PHP Standards Recommendations by the PHP Framework Interoperability Group are a good resource. AFAIK the standards are highly regarded. They attempt to be a collection and unification of what different frameworks have decided to use as their own standards.

I would say for basic PHP coding, especially PSR-1 and PSR-12 are well worth a read.

PSR-2′s purpose [was] to have a single style guide for PHP code that results in uniformly formatted shared code. [The PSR-12] specification extends, expands and replaces PSR-2, the coding style guide and requires adherence to PSR-1, the basic coding standard.

There are several accepted standard recommendations.

  • PSR-1: Basic Coding Standard
  • PSR-12: Extended Coding Style Guide
  • All PSRs
like image 89
Ilari Kajaste Avatar answered Sep 26 '22 05:09

Ilari Kajaste