This is just a simple howto so people can get started using phpdoc. Hopefully i'll have more time to write an in depth one at a latter date
Phpdocumentor can be used to document both object orientated code in classes and procedural code
The basic building block for this documentation is the docblock
A doclock starts with /** and ends with */, it is applied to the first element below that can be documented
define() statements, functions, classes, and class vars can be documented
More tags may be added in the future, not all tags are implemented at this time in phpdocumentor, however they are all recognized as tags and will at least be displayed
/** * The short description * * As many lines of extendend description as you want * Below this goes the tags to further describe element you are documenting * * @param type $varname description * @return type description * @access public or private * @author author name* @copyright name date * @version version * @see name of another element that can be documented, produces a link to it in the documentation * @link a url * @since a version or a date * @deprecated description * @exception Here since its in javadoc use as needed * @throws Here since its in javadoc use as needed * @package package name * @subpackage sub package name, groupings inside of a project */
Aditional info:
project and group aren't currently implemented but hopefully they will by the next version.
@project is used to group code into groups, usually used at the class level
@group does the same thing only its used for procedural code, so that functions can be grouped together
@param is a function parameter, you should have one tag for each function parameter, they should be in the same order as the function, you can have @param tags for parameters that aren't explicity listed in the function since you might be using func_get_args()
The code below is a sample class showing phpdoc in action
Not all formating of your phpdoc code has to be the same, but this is a recommened style since its easy to read in your code
/** * A sample class * * This class is just random php used as a phpdoc example * * @version 1.0 * @author Joshua Eichorn* @project test */ class phptestclass { /** * A sample class variable * @access private */ var $sample; /** * The class constructor * * This sets up the class and does other random stuff */ function phptestclass { $this->sample = "test"; } /** * A test function * * This function returns sample * * @return string */ function test () { return $this->sample; } /** * Set the sample var * * @param string $var */ function set($var) { $this->sample = $var; } }