RSS

PHP-GTK: Cross-platform desktop scripting

Written by: Chris in Product Reviews

PHP-GTK is a combination of PHP, a scripting language available to most major operating systems, and GTK, a set of libraries used to create GUIs (which are also available to most major operating systems). This combination allows users to easily create GUIs (with a language meant to easily create web sites) which can be used in Windows, Mac and Linux without additional work.  The script instructions are processed as necessary rather than compiled into a binary which would only work on one system.

This lack of binary form is both a positive and a negative.  It makes it more difficult to ship a completed application as an all-in-one program or installer (as that would require at least another application to do so such as a PHP compiler), but it allows anyone with PHP-GTK installed to simply download and execute the application.  If they examine and understand the PHP code, they will know exactly what the application is capable of.  It also allows the source code to be stored on another computer and be loaded on-the-fly from that server, allowing for unparalleled program updates which happen the moment the program has been updated.

Installing PHP-GTK is relatively simply for each operating system, but the steps are not the same.

Windows:

  • Getting PHP-GTK installed on Windows is relatively simple for someone with some technical background, but there currently is no installer for it (the aging Gnope aside).
  • Download PHP-GTK including it’s extensions, and extract it (You probably want it in C:\Program Files).
  • Optionally (for developing PHP-GTK applications), Download Glade (discussed later) and install it, which includes GTK on that page
  • Associate PHPW (and maybe PHP) files with PHP-GTK.

Mac:

  • Use the Mac OS X PHP-GTK installer; Unfortunately, it does not include the Glade libraries, which means you must install Glade itself to be able to use applications which used Glade.
  • Install Glade (I’ve not had time to test this, unfortunately).
  • Associate PHPW (and maybe PHP) files with PHP-GTK (?).

Linux (including Ubuntu):

  • Just use your favorite package manager to install PHP, GTK, and PHP-GTK, or compile them from source. Ubuntu users will find that PHP-GTK itself is not available from the package manager, and may which to use the generic Linux installer.
  • You may also wish to install Glade to help design GUIs.

I mentioned Glade in the installation steps; Glade is a GUI designer for Gnome/GTK, and thus will help you create the GUI portion of your PHP-GTK application without requiring you to place elements manually and trying to keep them all in mind.

There are plenty of tutorials out there, so I’m not going to rehash what they’ve already said. Instead, I’ll point you to some tutorials and sample applications I’ve found:

There’s another sample I wanted to link to, but I have not been able to locate where I got it from. I have been building my own PHP-GTK application, an RSS/Atom feed reader, using the SimplePie library. It is not here because it is not complete yet and is still in it’s alpha stages. However, I’d like to note that it was much simpler to create than with traditional C programming.

  • Share/Bookmark

Comments are closed.