PHP Depend - Software Metrics for PHP ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Author: Manuel Pichler :Date: Fri, 26 Jun 2009 22:35:33 +0200 :Revision: 4 :Copyright: CC by-nc-sa =============== Getting started =============== This guide will give a short introduction howto install and use the PHP_Depend software analyzer and metric tool. Installation ============ To get started with PHP_Depend you must install the latest version on your system. PHP_Depend should be installed using the `PEAR Installer`__. The installer is part of all PEAR and provides a distribution system for PHP packages. It shipped with every release of PHP since version 4.3.0. __ http://pear.php.net/manual/en/installation.php To install PHP_Depend you need to register its PEAR channel *pear.pdepend.org* that is used to distribute PHP_Depend: :: mapi@arwen ~ $ pear channel-discover pear.pdepend.org Adding Channel "pear.pdepend.org" succeeded Discovery of channel "pear.pdepend.org" succeeded Now that the PHP_Depend's PEAR channel is known to your PEAR environment you can install the PHP_Depend package from its channel: :: mapi@arwen ~ $ pear install pdepend/PHP_Depend-beta downloading PHP_Depend-0.9.4.tgz ... Starting to download PHP_Depend-0.9.4.tgz (161,553 bytes) ..................................done: 161,553 bytes install ok: channel://pear.pdepend.org/PHP_Depend-0.9.4 After the installation you can find the PHP_Depend source files inside your local PEAR directory. :: mapi@arwen ~ $ pear config-get php_dir /usr/local/share/pear mapi@arwen ~ $ ls /usr/local/share/pear/PHP Depend Depend.php Usage ===== You should test that PHP_Depend was correctly installed and can be used from the command line: :: mapi@arwen ~ $ pdepend --version PHP_Depend 0.9.4 by Manuel Pichler Now that PHP_Depend was installed correct and works, run PHP_Depend against its own source and generate a xml report and some charts. :: mapi@arwen ~ $ pdepend --summary-xml=/tmp/summary.xml \ --jdepend-chart=/tmp/jdepend.svg \ --overview-pyramid=/tmp/pyramid.svg \ /usr/local/share/pear/PHP/Depend PHP_Depend 0.9.4 by Manuel Pichler Parsing source files: ............................................................ 60 ............................ 88 Executing NPathComplexity-Analyzer: ........................................... 869 Executing Coupling-Analyzer: ........................................................... 1193 Executing NodeCount-Analyzer: ................................. 677 Executing Dependency-Analyzer: ................................... 703 Executing Hierarchy-Analyzer: ........................................... 880 Executing Inheritance-Analyzer: ..................... 421 Executing CodeRank-Analyzer: ...... 126 Executing CyclomaticComplexity-Analyzer: ........................................... 869 Executing ClassLevel-Analyzer: ....................................... 783 Executing NodeLoc-Analyzer: ............................................... 951 Generating pdepend log files, this may take a moment. Time: 00:13; Memory: 15.00Mb This command has produced one xml-report named *summary.xml* that contains a summary of all metrics collected for the analyzed php source code. :: ... ... ... ... And you will get to charts. The first one shows the inter package dependencies, similar to those charts generated by `JDepend`__ and the second one shows a visual summary of the analyzed project source code. __ http://clarkware.com/software/JDepend.html .. image:: images/jdepend.svg :align: left .. image:: images/pyramid.svg :align: left You should read the `software metrics`__ section of the documentation for further details on the metrics generated by PHP_Depend. __ /documentation/software-metrics.html