Showing posts with label gtk. Show all posts
Showing posts with label gtk. Show all posts

Wednesday, March 28, 2012

Using PHP-GTK to Serve Desktop Applications: Creating a Simple Interface

PHP-GTK is a library for PHP that provides an object-oriented interface to GTK+ classes and functions. Actually this is a little bit hard, so that is slow to develop itself. PHP-GTK uses object-oriented programming on it.

What is PHP-GTK?

GTK is a library to develop PHP and created by Andrei Ziminevski, you want to see him? There are some varieties about that, Scintilla, GtkHTML, etc.
According to some of us, Java, C++ or C# is better to use than PHP-GTK. But If the coder who knows how to code on PHP use it, PHP-GTK should be very simple to code. That's why is OOP kind of PHP 5.

Installing PHP-GTK for Windows
Had you set any plugin up before, you shall say that, installing PHP-GTK plugin is so hard, but actually is not'cuz you have to know something about that. First go this site: gtk.php.net or here and download gtk library. After that open the .rar or .zip file you've just downloaded.

Download gtk library: gtk.php.net
When you open this archive, just copy all folders to C:/
After this, open the winnt folder and copy the php.ini file, paste to php4 folder. And finish! You have finally finished the installing right now!
This one is for windows installation. If you want to install this package other system (Linux, MacOS something else), you can visit this official page.


The First GTK Project!
As we know, when the first project created, just done "hello world!". What we're gonna do is like that :) For this we need to php code and GTK library. that's it!
helloworld! MyFirstProject.php file

function clearThis() {
  Gtk::main_quit();
}
$window = new GtkWindow(); 
$window->connect('destroy','clearThis');

$window->set_border_width('50'); //Alert's width set as 50px.

$label = new GtkLabel("Hello World"); //Written Text sets here.
$window->add($label);

$window->show_all();
Gtk::main();
It is time to work the project. First open your windows command screen and follow this directory: c:\php4\php c:\php4\test\MyFirstProject
Output
Well, we have installed PHP-GTK library on C:/ and created the first project about it. As result, we can say, PHP language is not just for the web, can use it as desktop.


See you guys next article!