How to create PHP documentation in PhpStorm

PhpStorm displays your own code documentation in the code assist. But what if you wanted to create a separate documentation you can hand out or integrate into your website? Then you should use phpDocumentor. You can configure and run phpDocumentor directly from PhpStorm as an external tool. Here is what you have to do:

File -> Settings -> Select External Tools -> Add…

Installing phpDocumentor in phpStorm as an external tool

Screenshot showing how to install phpDocumentor in phpStorm as an external tool.

Provide the following data:

Name:  phpDocumentor
This name will show up in your Tools Menu. If you fill in a group such as PHP, then the entry will become a submenu of PHP.

Program: <pathToPhp.exe>
Fill in the path to your PHP executable, e.g. C:\Program Files\PHP\php.exe

Parameters: phpdoc -d “<pathToSourceDirectory>” -t “<pathToDestinationDirectory>” -o HTML:Smarty:PHP
The source directory is the one you want to document, e.g. where your php files reside in. The destination directory is where you want the documentation to be created in. Please note, that paths are given without th a trailing slash and  in case your paths contain spaces it is important to enclose the parameter in quotes.  For more information about the parameters see the phpDocumentor tutorial.

Working Directory: <pathToPhpDocumentor>
Fill in the path to your phpDocumentor directory, e.g. C:\Documents and Settings\Speich\My Documents\Website Tools\PhpDocumentor

In case you also wanted to create documentation for your JavaScript code, you should read the blog entry ‘How to create JavaScript documentation in PhpStorm‘.

3 thoughts on “How to create PHP documentation in PhpStorm

  1. I’ve also found the following is more transportable across projects (and with modification across OS’s?) by using the simplified “configuration” file parameter (-c config) found with the most recent versions of PHPDocumentor. You can find configuration examples in the ‘PHPDocumentor/user’ folder…just modify one and save it to your root project folder.

    Program: $PhpExecutable$
    Parameters: C:\xampp\php\phpdoc -c "$ProjectFileDir$"\phpdoc.ini
    Working directory: $ProjectFileDir$

  2. If you’re using Windows and XAMPP (Apache, MySQL, etc…), you may run into a problem with phpdoc being unable to find it’s .ini file. You’ll find a fix here. Of course you’ll need to have already installed PhpDocumentor via Pear. Start in xampp root xampp_shell.bat

    cd php
    pear channel-update pear.php.net
    pear install --alldeps PHPDocumentor

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>