Home > Information Technology | Linux System > Creating application based on PHP-GTK (Scratch)

Creating application based on PHP-GTK (Scratch)

Requirements:

  • Ubuntu Gutsy Gibbon
  • Additional programs: checkinstall, PHP5, PHP-Devel

Compiling and Installing

  1. Install libgtk2.0-dev and its required packages.
  2. Download PHP-GTK (I use PHP0-GTK 2.0) and then compile it:
    ./buildconf
    ./configure
    make

    If you are asked for phpize, then it means you have to install php-devel.

  3. Convert this binary into .deb package for easier removal (if you want to remove it later):
    checkinstall
  4. Add the following line in the php5.ini (for CLI, not Apache):
    extension=php_gtk2.so

Optional packages:

  1. Libglade : A package to help make designing the layout easier.
  2. Scintilla : A powerfull text editing widget.
  3. GdkPixbuf : A package for manipulating and drawing images in a GTK-based application.
  4. GtkHTML : A widget for displaying HTML like a web browser. GtkHTML has a number of dependencies. Make sure you install all of those first.

For rapid development, use Glade to build GUI. If you got error like this:
function not found GladeXML()
Try to install some Glade package, then recompile and reinstall your PHP-GTK.

Testing

Make PHP file with the following content:
<?php
$window = new GtkWindow();
$window->connect_object('destroy', array('Gtk', 'main_quit'));
$dateTime = new GtkLabel(date('Y-m-d H:i:s'));
$window->add($dateTime);
$window->show_all();
Gtk::main();
?>

Save it to test.php, and try execute it by typing on shell:
php test.php
If there isn’t any new window appear, your installation may fail.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 

Trackbacks:0

Listed below are links to weblogs that reference
Creating application based on PHP-GTK (Scratch) from Aji's Journal
TOP