Tag Archives: job

Integrate PHP_Depend with phpUnderControl

The newest version of phpUnderControl has now basic support for PHP_Depend. With PHPUnit deprecating support for metrics, it’s just about the time to switch. And it’s not as complicated as it might sound.

First of all you need to install PHP_Depend. Using pear it’s the easiest and quickest way to do it. If you haven’t registered PHP_Depend pear channel yet, it is time to do it now:

141:~ sebmarek$ sudo pear channel-discover pear.pdepend.org
Adding Channel "pear.pdepend.org" succeeded
Discovery of channel "pear.pdepend.org" succeeded

After that simply use pear to install the latest version of PHP_Depend:

141:~ sebmarek$ sudo pear install pdepend/PHP_Depend-beta
Did not download optional dependencies: pecl/imagick, use --alldeps to download automatically
pdepend/PHP_Depend can optionally use package "pecl/imagick" (version >= 2.2.0b2)
downloading PHP_Depend-0.9.11.tgz ...
Starting to download PHP_Depend-0.9.11.tgz (323,787 bytes)
..................................................................done: 323,787 bytes
install ok: channel://pear.pdepend.org/PHP_Depend-0.9.11

and confirm that PHP_Depend installed successfully:

141:~ sebmarek$ pdepend --version
PHP_Depend 0.9.11 by Manuel Pichler

The next step is to modify your project’s build file. If you don’t use phpunit configuration xml file the change is really simple. Just remove –log-metrics option from your phpunit ant task:

<target name="phpunit">
    <exec dir="/pth/to/your/module" executable="phpunit" failonerror="true">
        <arg line="--log-junit ${basedir}/build/logs/phpunit.xml
                   --log-metrics ${basedir}/build/logs/phpunit.metrics.xml
                   --coverage-xml ${basedir}/build/logs/phpunit.coverage.xml
                   --coverage-html ${basedir}/build/coverage" />
    </exec>
</target>

If you use phpunit xml file remove relevant entry from logging section:

<logging>
    <log type="coverage-html" target="/path/to/build/coverage/" charset="UTF-8" yui="true" highlight="false" lowUpperBound="35" highLowerBound="70"/>
    <log type="coverage-clover" target="/path/to/build/logs/phpunit.coverage.xml"/>
    <log type="junit" target="/path/to/build/logs/phpunit.test.xml" logIncompleteSkipped="true"/>
    <log type="metrics-xml" target="/path/to/build/logs/metrics.xml"/>
</logging>

Finally just add new ant task in the build file that will run pdepend and generate metrics xml file and additional graphs.

<target name="php-depend">
    <exec executable="pdepend" dir="${basedir}/Source" logerror="on">
        <arg line="--phpunit-xml=${basedir}/build/logs/pdepend.xml
                   --jdepend-chart=${basedir}/build/graph/08-dependencies.svg
                   --overview-pyramid=${basedir}/build/graph/09-software-metrics-pyramid.svg
                   . " />
    </exec>
</target>

<target name="phpunit">
    <exec dir="${basedir}/Source/Test/" executable="phpunit" failonerror="true" />
</target>

<target name="build" depends="clean,checkout-code,php-documentor,php-codesniffer,php-depend,phpunit" />

Now either wait until next build happens or simply trigger the next build manually and navigate to the metrics tab. All the charts should be still there. In addition two additional charts has been added – Package Dependencies and visual summary of the analyzed project source code.

PHP_Depend metrics

Additional charts generated with PHP_Depend

Package dependencies chart is also shown at the top of phpUnderControl Overview tab.

To learn more about software metric and PHP_Depend itself have a look at Documentation section at http://www.pdepend.org/

Wind of changes

I definitely have to plan my actions more carefully. Trying to do too many things at the same doesn’t seem to work. I need a plan. Like 10 years plan. Hmm, maybe not 10 years, communists tried that once (or two) and it didn’t work for them very well. So maybe next year plan? In fact, new year comes, so it’s a quite good opportunity to sort things out. My Missus is out, kids in beds, nice and quite. Let’s think then what I could do next year.

1. Focus

I have to focus on one thing, get it done and move on. There is a few things a need to improve and some priorities needs to be assigned.

2. Separation

My professional life needs separating from the personal one. And it’s clear here – The Family takes priority. The rest comes after.

3. Arrangement

  • Make small steps – but regularly.
  • Make notes – often.
  • Speak to people – always.
  • Constantly improve – learn your lesson.

Quite generic, but sums things up.

Ready… steady… go!

I have refreshed the blog then. Found new theme, more toned! I started to use it wrong, these few random post fits more for a wiki then a blog. Will stop that.

Next, finish what you have started. I will focus on the current task and get it finished by end of next week. This deadline sounds reasonable. Next update – Monday evening then. Remember! Small steps, but regularly.