Desktop programming with PHP!

13 Aug
php-gtk.gif GTK is an interesting library of php. This library used for desktop application.
Yap! No kidding here. Php is not only using for server side language. We can develop desktop based application also.Recently PHP-GTK2 is released for PHP5 with documentation. A strong forum also developed for developers.I am really exited about it.After installing GTK we can start an example.


//Step 1
if (!class_exists(‘gtk’)) {
die(“Please load the php-gtk2 module in your php.ini”);

//Step 2
$wnd = new GtkWindow();

//Step 3
$wnd->set_title(‘Hello world’);
$wnd->connect_simple(‘destroy’, array(‘gtk’, ‘main_quit’));//step 4
$lblHello = new GtkLabel(“Hello world!'”);

//step 5


This is a sample program for GTK.
Type it in a simple text editor like notepad and save as sample.phpw

It is good practice to check is GTK package available or not. So in first step we should check it.

In second step we make an object of window and in third step we attach the title of the window. In fourth step we add a level to show a message

And in final step we just say the console to display it.

This is the source code of the program now how you should run it.

Don’t be confuse that this is a desktop based application so don’t think about the we server. We will run it there.

To just test you can do a easy way. But before it I am admitting this is not good process. You can copy the source file in your PHP folder and open the dos console. And just go to the file location and run it like other java program( type: C:/wamp/php>php sample.phpw)

If you find the message
“Please load the php-gtk2 module in your php.ini”
it means you did not install GTK2 yet.

Otherwise a window will popup for you. This is amazing.


2 Responses to “Desktop programming with PHP!”

  1. Sam October 26, 2008 at 11:49 pm #

    Wow, that’s awesome!


  1. Delphi ile C++ - Sayfa 2 - Ceviz Forum - October 10, 2009

    […] […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: