PHP Coding Conventions

coding style and more for the rdb2oo project.

Dipl.-Kfm. Michael H.E. Roth

Revision History
Revision $Revision: 1.5 $$Date: 2002/12/16 14:38:33 $$Author: mher $

Table of Contents

Organization of php-classes
Coding Style
Commenting of source-code

Abstract

This document is about the style how we will organize and name the php classes.

As well as some other coding styles.

Organization of php-classes

To make sure the will be no name-conflicts with other classes developed by other developers, we adapted the Java organization- and naming conventions for our php-classes as well.

What does that mean?

All php-classes should be in a directory structure like this:

<top-level-domain>/<domain-name>/<project-name>/[<evtl-subproject>/]
    
de/mher/rdb2oo/
      

The filename of the class (always just one class per file) is always <class-name>.class.php

createcode.class.php
      

The class name itself is now <top-level-domain>_<domain-name>_<project-name>_[<evtl-subproject>_]<class-name>.

de_mher_rdb2oo_createcode
      

The directory tree then has to be in the php-configuration-parameter include_path.

Create a directory i.e. classes/ somewhere in a directory you have access to and put the directory tree in that directory, then add the path to this directory to the php-configuration-parameter include_path.

If you don't have access to the php.ini file, you still can redefine this parameter in the .htaccess file (if you are using apache, currently I'm not using php on IIS so at the moment I cannot tell how that works there). But here is what you have to put in your .htaccess file:

php_value include_path .:<path_to_your_classes_directory>:<path_to_the_PEAR_repository>:<evtl_other_include_path_directories>
    
php_value include_path .:/home/mher/htdocs/classes/:/usr/lib/php/