# D-Bus(ing) via PHP - Zombie Quick Posts

Published: 2011-09-26
Tags: Zombie Quick Posts, d-bus, example, pecl, php, screenshot

<p>Ever heard of <a title="D-Bus" href="http://www.freedesktop.org/wiki/Software/dbus">D-Bus</a> ? Do you use PHP ? Cool, here's a quick note on how to get the two going, I'll get back to this later on (in life)</p>
<p>&nbsp;</p>
<h2>Installing the PECL D-Bus extension</h2>
<blockquote><p>sudo pecl install channel://pecl.php.net/dbus-0.1.1</p></blockquote>
<h2>Write some php (dbus.php)</h2>
<pre class="brush:php">&lt;?php

$DBus = new Dbus( Dbus::BUS_SESSION );

$DBusProxy = $DBus-&gt;createProxy
    (
        "org.gnome.Shell", // connection name
        "/org/gnome/Shell", // object
        "org.gnome.Shell" // interface
    );

$DBusProxy-&gt;Screenshot("/tmp/test_php.jpg");</pre>
<h2>Run it</h2>
<blockquote><p>php dbus.php</p></blockquote>
<h2>Yay or nay, have fun</h2>
<p>This quick example should - If all the stars align and your current Operating System actually has D-Bus and Gnome Shell installed - take a quick snapshot of your desktop, now, it wasn't impressive (not by a long shot), but it was something I randomly picked using <a href="http://live.gnome.org/DFeet/">D-Feet</a> to test the extension and lo and behold, it worked, like a charm, the first time. What more can we ask :)</p>
<p>We'll be back, I just wanted to dump this info here :)</p>
<p>&nbsp;</p>
