List of highly-regarded PHP style guides?

偶尔善良 提交于 2019-12-18 10:33:19

问题


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.


回答1:


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-2 are well worth a read.

PSR-2′s purpose is to have a single style guide for PHP code that results in uniformly formatted shared code.

So far, there are four accepted standard recommendations:

  • PSR-1: Basic Coding Standard
  • PSR-2: Coding Style Guide
  • PSR-3: Logger Interface
  • PSR-4: Autoloader Standard (PSR-0 alternative)

Deprecated:

  • PSR-0: Autoloader Standard



回答2:


I just use the PEAR coding standards.

http://pear.php.net/manual/en/standards.php




回答3:


This is really for Codeigniter, but it's still PHP and an easy read and I like the styles used:

http://ellislab.com/codeigniter/user-guide/general/styleguide.html



来源:https://stackoverflow.com/questions/3638083/list-of-highly-regarded-php-style-guides

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!