My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for

English, Русский, Deutsche, French, Italiano, Türkçe, Nederlandse


phpDays - flexible php5 framework based on the MVC and ORM design patterns.

Start now

  • About the project (features)
  • Changelog (changes between project versions)
  • Install the framework on your server and then configure a new project
  • Upgrade an application from a previous version
  • Quick start to get your first application up and running
  • Answers to your questions
  • All pages in English

Every day use

  • MVC - basic concepts necessary to work with the framework
  • Library class reference descriptions
  • Ajax support in your applications
  • Multisite - manage many sites from one framework installation

For project members

EnCodingStyle  
Coding style.
Lang-En
Updated Dec 7, 2009 by anton.danilchenko

To participate in the project phpDays you should follow the same coding style (syntax for php, html, css, js and yaml files).

General rules

  • save all files and folders in lower case only (use file_name.html instead of fileName.html). In Windows this create a problems
  • recommend a development environment IDE NetBeans (but can be used and other such as Eclipse PDT)
  • keep all the files in UTF-8 encoding
  • newlines must be in UNIX format
  • configure the IDE to automatically remove extra spaces at the end of lines (trailing spaces)
  • configure the IDE to automatically replace tabs by 4 spaces in php files and 2 spaces in all other (including html, css, js and yaml files)

Code sample

class Days_Model_User {
  // first position for constants: usee capital letters
  const USER_FIELD = 'username';
  // second position: properties. For private and protested properties use "_" prefix
  private $_name;
  protected $_name2;

  // third position: methods
  public static function test($x) {
    if (10==$x) {
       return true;
    }
    return false;
  }

  // before function definition set only one empty line
  protected function _test2($x, $y=10) {
    // not use empty lines into function code
    if ($x==$y) {
       return true;
    }
    return false;
  }
}

Autoformat your code

Use this regular expressions for automatically format code:

From To Description
\t 4 spaces replace tab to 4 spaces
[ ]+$ delete all spaces in end of line
!([a-z$]) ! $1 set space after not operator
^[\t ]*\n delete empty lines
else *\n([ ]*)\{ else\n$1{ set { after else
if( if ( use space after if and elseif
\)[ ]*\n[ ]*\{ ) {\n set java code style
^([ ]*)(public|protected|private) \n$1$2 set { in line with function

Rules for work with php files

Safety Information:


Sign in to add a comment
Powered by Google Project Hosting