How to install PHP-GTK in Ubuntu 7.10

Devolio

Search

Tuesday, February 12. 2008

How to install PHP-GTK in Ubuntu 7.10

Just as described on their site,
"PHP-GTK is an extension for the PHP programming language that implements language bindings for GTK+. It provides an object-oriented interface to GTK+ classes and functions and greatly simplifies writing client-side cross-platform GUI applications."

Basically, it will allow you to use almost everything in the GTK+ API with PHP. If you don't already know what GTK+ is, GTK+ is an API for creating a graphical user interface, which also happens to be cross platform (Linux, Windows, and Mac.) Today we're going to cover installing PHP-GTK in Ubuntu 7.10 (Gutsy).
Alright, let's get down to business.

Setup


First thing we're going to do, if you haven't already at sometime or another, is install the build essentials. We can do this by opening a terminal (Applications->Accessories->Terminal) and typing
sudo apt-get install build-essential


Next, we need to install the packages required to use GTK (and cvs, assuming you do not have it):
sudo apt-get install php5-cli php5-dev php5-gd libgtk2.0-dev libglade2-dev cvs


Now we're ready to grab the files we need. Let's go ahead and connect to the repository with cvs:
cvs -d :pserver:cvsread@cvs.php.net:/repository login


It will ask you for a password, just press enter. Now we'll checkout the files with cvs:
cvs -d :pserver:cvsread@cvs.php.net:/repository co php-gtk


Once that's completed, we can switch to the php-gtk directory, using
cd /home/username/php-gtk


Making sure to replace 'username' with your username, cd into it's directory. We're finally ready. Let's build php-gtk.

Building and Installing


First buildconf,
./buildconf


Once that finishes, we can configure...
./configure


And make...
make


And lastly, make and install it.
sudo make install


Now we have php-gtk and everything we need installed, we need to include the PHP-GTK extension in our php.ini, using $anyeditor. I happen to like gedit.
sudo gedit /etc/php5/cli/php.ini


About halfway down (or by searching/grepping for 'Extensions',) you can include the extension by using:
extension=php_gtk2.so


Once that's saved, we can restart apache and test out php-gtk. Let's go ahead and restart apache...
sudo /etc/init.d/apache2 restart


Testing


And once apache is restarted, we can see if PHP-GTK is ready using
php -m | grep php-gtk


As long as you get the confirmation-
php-gtk


You're ready to start writing client side desktop applications. You can check out the PHP-GTK Documentation or tutorials for some ideas on how to use it. Sometime in the near future, I'll be putting up some tutorials for PHP-GTK with some demos. Have an idea for a fun demo, or advice on using PHP-GTK? Leave a comment, I appreciate them all.

Trackbacks

No Trackbacks

Comments
Display comments as (Linear | Threaded)

#1 - holle 2008-03-03 16:21 - (Reply)

Finally, a tutorial that worked for me, fantastic. The only thing I've been missing on *nix

Thx a bunch

#2 - Nick 2008-03-04 18:59 - (Reply)

hi, I had installed php-gtk, it's ok , I can run the demos by command line , but...... I cant open php files on my localhost: php I cant run php with apache. What can I do?

#2.1 - Joey said:
2008-03-04 21:30 - (Reply)

Nick,

PHP-GTK is pretty much for running Desktop apps only, as far as I know (and someone please correct me if I'm wrong,) you can only run them locally via the command line.


Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications