Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Coding convention to follow for PHP? [closed]

Should I stick with Sun's Java code conventions for PHP code?

like image 573
Igor Drincic Avatar asked Sep 26 '08 13:09

Igor Drincic


2 Answers

You should be following one of the PSR standards for PHP approved by the Framework Interop Group

  • PSR-0 - Aims to provide a standard file, class and namespace convention..
  • PSR-1 - Aims to ensure a high level of technical interoperability between shared PHP code.
  • PSR-2 - Provides a Coding Style Guide for projects looking to standardise their code.
  • PSR-3 - Describes a common interface for logging libraries; the LoggerInterface exposes eight methods to write logs to the eight RFC 5424 levels.
  • PSR-4 - Describes a specification for autoloading classes from file paths. It is fully interoperable, and can be used in addition to any other autoloading specification, including PSR-0.
like image 122
Justin Avatar answered Oct 11 '22 11:10

Justin


For PHP, i'd suggest to follow Zends suggestions

As you might know, Zend is the most widely used framework!

like image 24
prakash Avatar answered Oct 11 '22 11:10

prakash