PPH Coding convention

Are you the person who has moved from JAVA to PHP and you are confused about PHP coding convention? Then this is place for you.

Following are the cases in which you define everything
1. PascalCase = ThisIsMyClass
2. camelCase = thisIsMyClass
3. lower_case = this_is_my_variable

NOTE: Difference between Pascal case and camelCase is first character of the word.

A brief comparison of what coding convention is followed by different PHP frameworks

╔═══════════════════════╦═════════════╦════════════╦══════════════╦════════════╦════════════╗
║ PHP Project ║ Classes ║ Methods ║ Properties ║ Functions ║ Variables ║
╠═══════════════════════╬═════════════╬════════════╬══════════════╬════════════╬════════════╣
║ Akelos Framework ║ PascalCase ║ camelCase ║ camelCase ║ lower_case ║ lower_case ║
║ CakePHP Framework ║ PascalCase ║ camelCase ║ camelCase ║ camelCase ║ camelCase ║
║ CodeIgniter Framework ║ Proper_Case ║ lower_case ║ lower_case ║ lower_case ║ lower_case ║
║ Concrete5 CMS ║ PascalCase ║ camelCase ║ camelCase ║ lower_case ║ lower_case ║
║ Doctrine ORM ║ PascalCase ║ camelCase ║ camelCase ║ camelCase ║ camelCase ║
║ Drupal CMS ║ PascalCase ║ camelCase ║ camelCase ║ lower_case ║ lower_case ║
║ Joomla CMS ║ PascalCase ║ camelCase ║ camelCase ║ camelCase ║ camelCase ║
║ modx CMS ║ PascalCase ║ camelCase ║ camelCase ║ camelCase ║ lower_case ║
║ Pear Framework ║ PascalCase ║ camelCase ║ camelCase ║ ║ ║
║ Prado Framework ║ PascalCase ║ camelCase ║ Pascal/camel ║ ║ lower_case ║
║ SimplePie RSS ║ PascalCase ║ lower_case ║ lower_case ║ lower_case ║ lower_case ║
║ Symfony Framework ║ PascalCase ║ camelCase ║ camelCase ║ camelCase ║ camelCase ║
║ WordPress CMS ║ ║ ║ ║ lower_case ║ lower_case ║
║ Zend Framework ║ PascalCase ║ camelCase ║ camelCase ║ camelCase ║ camelCase ║
╚═══════════════════════╩═════════════╩════════════╩══════════════╩════════════╩════════════╝

As developers we should follow following protocol
ClassName = PascalCase
methodName = camelCase
propertyName = camelCase
function_name = lower underscroe
variable_name = lower underscore


There are no comments.

Leave a Reply