Coding standard for PHP 5.3 and above.
Namespaces
All packages should be named:
<vendor>\<package_or_component>\<ClassName>
For example:
pear2\text_diff\Diff
zend\controller\FrontController
cake\models\DatabaseModel
- Namespaces must be lowercase
- Each package must have a vendor and a top-level namespace at a minimum
- Each package can have as many sub-namespaces as it wishes
- Each namespace separator is converted to a DIRECTORY_SEPARATOR when loading from the file system
- Underscores within namespaces have no significant meaning
Class, Interface, and Abstract Names
- All class names must begin with an uppercase character
- All class names may contain underscores
- Any underscores within class names must denote a DIRECTORY_SEPARATOR
- All interfaces must be suffixed with Interface
- All abstracts must be suffixed with Abstract
Exception Naming
- All packages must declare at package level Exception (i.e., pear2\text_diff\Exception)
- All packages should use SPL Exceptions where applicable
- Package level Exceptions may be concrete classes, or interfaces
- All Exceptions thrown within a package should extend or implement the package level Exception