01 - Indenting and Line Length
Mambo Coding Standards
Mar 03, 2007 at 10:36 AM

Use an indent of 4 spaces, with no tabs. If you use Emacs to edit PEAR code, you should set indent-tabs-mode to nil. Here is an example mode hook that will set up Emacs according to these guidelines (you will need to ensure that it is called when you are editing PHP files):

(defun php-mode-hook ()
  (setq tab-width 4
        c-basic-offset 4
        c-hanging-comment-ender-p nil
        indent-tabs-mode
  (not
    (and (string-match "/\\(PEAR\\|pear\\)/" (buffer-file-name))
      (string-match "\.php$" (buffer-file-name))))))

Here are vim rules for the same thing:
set expandtab
set shiftwidth=4
set softtabstop=4
set tabstop=4

It is recommended that you break lines at approximately 75-85 characters. Note that if the line spans longer than 80 characters each element should be broken into its own line, and indented one level:
eg.

$form['title'] = array(
  '#type' => 'textfield',
  '#title' => T_('Title'),
  '#size' => 60,
  '#maxlength' => 128,
  '#description' => T_('The description.'),
)

Next>

The Mambo Foundation is a volunteer non-profit organization and relies entirely upon the financial and human resource donations of the wider Mambo open source community to keep Mambo going.

We need your support!
Please make a donation today.