November 15, 2012

Installing PhpDocumentor (and PEAR)


I need to learn to document better. I've always done a halfway decent job, but my method is slow and somewhat redundant. Time to pull in a good tool to help me out.
I'm working on a local wamp host. PhpDocumentor says I should install using PEAR. Well that's great - I don't have PEAR installed.

I found this video and followed most of the instructions.
Note that his first execution of go-pear uses the incorrect extension (.php instead of .phar)
Here were my steps:
  1. Download go-pear from http://pear.php.net/go-pear.phar and store it in my php directory
  2. Open my command prompt, navigate to my php directory and run

    php go-pear.phar
  3. At each prompt, I simply press enter, accepting the defaults
With pear installed, I now just need to install phpDocumentor in two simple steps:

pear channel-discover pear.phpdoc.org
pear install phpdoc/phpDocumentor-alpha

I'm hoping that's all I need to do. Let's give it a test run.

First Attempt

With no expectation that this will actually work the first time, I run this:

phpdoc run -d my\code\path -t \my\target\path

Bummer! Well it was wishful thinking anyway. Here's what I see:

[phpDocumentor\Plugin\Core\Exception]
The XSL writer was unable to find your XSLTProcessor; please check if you have installed the PHP XSL extension

I'm not familiar with this extension, although I'm fairly certain I've seen it mentioned enough that I should become acquainted with it. A quick Google search nets me this Stack Overflow post where a DocBlox user has encountered the same problem. Apparently wamp did not enable the xsl extension for php. Opening up php.ini I search for "xsl" and find this:

;extension = php_xsl.dll

I remove the semicolon to uncomment this line and save. Out of habit, I restart all my wamp services as well.

Second Attempt

I run the same commmand again:

phpdoc run -d my\code\path -t \my\target\path

I'm pleasantly surprised this time. It did throw some questions about GraphViz being installed, but it seems to have worked. Since my target path was in web directory I can now browse to the compiled documentation on my localhost. Pretty spiffy. And not too bad of a process.

Update: I've since researched GraphViz and it provides a neat way to visualize your class hierarchy when properly installed. It is completely optional. I personally have not found it useful yet, but plan to keep it around. You can download it here.

No comments:

Post a Comment