PHP_Depend jumps on the D-BUS

Today I had the chance to visit Derick's IPC talk PHP on the D-BUS. Beside the fact that it was an exciting talk, it inspired me to implement a small, but nice feature for PHP_Depend using the pecl/dbus extension.

PHP_Depend jumps on the D-BUS

Sometimes the parsing and analysis process of PHP_Depend can consume a lot of time to finish, so I always put the shell aside and do something different. Normally I take a look at the shell every few minutes to check if the process has finished, but it also happens that I totally forget that I have started a PHP_Depend process on my system. So I need something that says to me, "Hey, mapi PHP_Depend has finished its job...", and here comes D-BUS in the game.

With D-BUS it is really simple to send a message to a desktop notification panel, as it is available for desktop environments like Gnome or KDE. To use D-BUS in your php applications you must checkout the source code of pecl/dbus from the svn repository and compile it for your php installation.

mapi@arwen ~ $ svn co http://svn.php.net/repository/pecl/dbus/trunk \
               pecl-dbus
mapi@arwen ~ $ cd pecl-dbus
mapi@arwen pecl-dbus $ phpize
mapi@arwen pecl-dbus $ ./configure
mapi@arwen pecl-dbus $ make
mapi@arwen pecl-dbus $ sudo make install

That's it. Now you should see the --notify-me option when you open PHP_Depend's help screen.

mapi@arwen ~ $ ~/pdepend/pdepend.php --help
PHP_Depend @package_version@ by Manuel Pichler

// ... snipp ...

  --debug                   Prints debugging information.
  --help                    Print this help text.
  --version                 Print the current version.
  --notify-me               Show a notification after analysis.
  -d key[=value]            Sets a php.ini value.

Now you can add this option to your normal PHP_Depend command and it will show a notification window with the number of analyzed files and the time the process took.

mapi@arwen ~ $ ~/pdepend/pdepend.php --summary-xml=/tmp/summary.xml \
                                       --notify-me \
                                       ~/pdepend/PHP

For the moment this feature is only available through the 0.9.0 branch of PHP_Depend and not as a PEAR package.

Tags:

Categories:

Published: November 18, 2009