The Zend Framework employs a class naming convention whereby the names of the classes directly map to the directories in which they are stored. The root level directory of the Zend Framework is the "Zend/" directory, under which all classes are stored hierarchially.
Class names may only contain alphanumeric characters. Numbers are permitted in class names but are discouraged. Underscores are only permitted in place of the path separator -- the filename "Zend/Db/Table.php" must map to the class name "Zend_Db_Table".
If a class name is comprised of more than one word, the first letter of each new word must be capitalized. Successive capitalized letters are not allowed, e.g. a class "Zend_PDF" is not allowed while "Zend_Pdf" is acceptable.
Zend Framework classes that are authored by Zend or one of the participating partner companies and distributed with the Framework must always start with "Zend_" and must be stored under the "Zend/" directory hierarchy accordingly.
These are examples of acceptable names for classes:
Zend_Db Zend_View Zend_View_Helper
IMPORTANT: Code that operates with the framework but is not part of the framework, e.g. code written by a framework end-user and not Zend or one of the framework's partner companies, must never start with "Zend_".
Interface classes must follow the same conventions as other classes (see above), however must end with the word "Interface", such as in these examples:
For all other files, only alphanumeric characters, underscores, and the dash character ("-") are permitted. Spaces and are prohibited.
Any file that contains any PHP code must end with the extension ".php". These examples show the acceptable filenames for containing the class names from the examples in the section above:
Zend/Db.php Zend/Controller/Front.php Zend/View/Helper/FormRadio.php
File names must follow the mapping to class names described above.
Function names may only contain alphanumeric characters. Underscores are not permitted. Numbers are permitted in function names but are discouraged.
Function names must always start with a lowercase letter. When a function name consists of more than one word, the first letter of each new word must be capitalized. This is commonly called the "studlyCaps" or "camelCaps" method.
Verbosity is encouraged. Function names should be as verbose as is practical to enhance the understandability of code.
These are examples of acceptable names for functions:
filterInput() getElementById() widgetFactory()
For object-oriented programming, accessors for objects should always be prefixed with either "get" or "set". When using design patterns, such as the singleton or factory patterns, the name of the method should contain the pattern name where practical to make the pattern more readily recognizable.
Functions in the global scope ("floating functions") are permitted but discouraged. It is recommended that these functions should be wrapped in a static class.
Variable names may only contain alphanumeric characters. Underscores are not permitted. Numbers are permitted in variable names but are discouraged.
For class member variables that are declared with the "private" or "protected" construct, the first character of the function name must be a single underscore. This is the only acceptable usage of an underscore in a function name. Member variables declared "public" may never start with an underscore.
Like function names (see section 3.3, above) variable names must always start with a lowercase letter and follow the "camelCaps" capitalization convention.
Verbosity is encouraged. Variables should always be as verbose as practical. Terse variable names such as "$i" and "$n" are discouraged for anything other than the smallest loop contexts. If a loop contains more than 20 lines of code, the variables for the indices need to have more descriptive names.
Constants may contain both alphanumeric characters and the underscore. Numbers are permitted in constant names.
Constants must always have all letters capitalized.
Constants must be defined as class members by using the "const" construct. Defining constants in the global scope with "define" is permitted but discouraged.