PHPDocumentor is a fast and convent way of creating API documentation for your PHP programs and classes. If you are familiar with the world of Java, it works in much the same way as the JavaDoc program, indeed, it is based on this program.
PHPDocumentor can be run in a number of different ways, but I have found that the easiest way is to, again, use PEAR to install everything you need. To install PHPDocumentor using PEAR use the following command.
phpdoc install phpdocumentor
To run PHPDocumentor and see a list of commands just type in the following:
To run PHPDocumentor you need to provide a couple of options, these are:
- t The documentation directory (ie. where your documentation files will go).
- o The output format (e. HTML, PDF etc), which is defined as output:converter:template directory.
- d The directory (ie. where your source code files are).
Use the following syntax to run PHPDocumentor, using the above parameters.
C:\projectDir>phpdoc -t "c:\projectDir" -o HTML:default:default -d "c:\projectDir\docs"
The output format defined here is HTML, with the default style and format. This is as a document with frames and in the default style that the program uses. To see what sort of formats are available go to the PHPDocumentor install directory at
To get a different style on your PHPDocs use the following value for the -o parameter.
To create a PDF of your documentation use the following.
To product output that looks like the PHP home page use the following:
You might be asking how you get your PHP code to generate this documentation. Although this is not complicated, there is rather a lot to go over and so this will be the subject of a different blog post.