Install PHPDocumentor

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:

phpdoc -h

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 <your PHP directory>\data\PhpDocumentor\phpDocumentor\Converters.

To get a different style on your PHPDocs use the following value for the -o parameter.

HTML:default:l0l33t

To create a PDF of your documentation use the following.

PDF:default:default

To product output that looks like the PHP home page use the following:

HTML:smarty:php

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.

Add new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
4 + 4 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.