phpDocumentor is a tool which creates complete documentation like Javadocs for PHP code.
Installing phpDocumentor
$ sudo apt-get install libapache2-mod-php5
Restart Apache
$ sudo service apache2 restart
Install PEAR. PEAR is a repository of php extensions
$ sudo pear config-set data_dir /var/www
Tell PEAR where to install phpDocumentor
$ sudo pear install --alldeps phpDocumentor
www-data is user Apache on Ubuntu
$ sudo mkdir /var/www/phpDocumentorOuput $ sudo chown www-data /var/www/phpDocumentorOutput
Using phpDocumentor
You can use phpDocumentor on commandline or via a web interface. For the web interface, type the following http://localhost/phpDocumentor in your browser. Click on Files tab and provide address of the file or directory your intend to create documentation for. Then click on output and specify the output directory. Then hit create button.
On commandline:
Create an output directory and assign proper permissions:
$ sudo mkdir /var/www/docs $ sudo chown my-user_account /var/www/docs $ sudo 644 /var/www/docs
Create documentation for one file:
$ phpdoc -d /var/www/my_code_directory/my_code.php -t /var/www/docs
Create documentation all files in a directory and its subdirectories:
$ phpdoc -d /var/www/my_code_directory -t /var/www/docs
Change the look of the documented code
$ phpdoc -o HTML:frames:earthli -d /var/www/my_code_directory -t /var/www/docs
Both javadoc and phpdoc generate documentation for public and protected methods/functions, and variables. All private variables and methods/functions are ignored. To include private variables and functions, add the -pp option as follows:
$ phpdoc -pp -d /var/www/my_code_directory -t /var/www/docs