In his recent blog post, Piotr Pokora showed how the the D-Bus API will work in Midgard 2. D-Bus is an interprocess communications system that is used heavily in modern Linux desktops like GNOME and KDE. With Midgard, the same system now becomes available for PHP and web applications:
import dbus.mainloop.glib import _midgard as midgard def mbus_callback(object, arg): print "Hi! I am midgard_dbus from midgard-python. I got message:" print object.get_message() mbus = midgard.dbus("/midgard_article") mbus.connect("notified", mbus_callback, "foo") mainloop = gobject.MainLoop() mainloop.run()
$message = "Greetings from midgard-php!(" . mgd_version() . ") PHP ver." . phpversion(); midgard_dbus::send("/midgard_article", $message);
I started php script which immidietialy[sic] ended, and on midgard-python service's terminal I got this message:
Hi! I am midgard_dbus from midgard-python. I got message: Greetings from midgard-php! (2.0alpha0) PHP ver.5.2.5-3
This is a major milestone in our greater plan for the future of Midgard, and should be interesting to also other PHP and web application developers.
Good work, Piotras!