PHP-GTK
Encyclopedia
PHP-GTK is a set of language binding
Language binding
In computing, a binding from a programming language to a library or OS service is an API providing that service in the language.Many software libraries are written in systems programming languages such as C or C++...

s for PHP
PHP
PHP is a general-purpose server-side scripting language originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document...

 which allow GTK+
GTK+
GTK+ is a cross-platform widget toolkit for creating graphical user interfaces. It is licensed under the terms of the GNU LGPL, allowing both free and proprietary software to use it. It is one of the most popular toolkits for the X Window System, along with Qt.The name GTK+ originates from GTK;...

 GUI
Graphical user interface
In computing, a graphical user interface is a type of user interface that allows users to interact with electronic devices with images rather than text commands. GUIs can be used in computers, hand-held devices such as MP3 players, portable media players or gaming devices, household appliances and...

 applications to be written in PHP
PHP
PHP is a general-purpose server-side scripting language originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document...

. PHP-GTK provides an object-oriented interface to GTK+ classes and functions.

History

PHP-GTK was originally conceived by Andrei Zmievski, who is also actively involved in the development of PHP
PHP
PHP is a general-purpose server-side scripting language originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document...

 and the Zend Engine
Zend engine
The Zend Engine is an open source scripting engine , commonly known for the important role it plays in the web automation language PHP. It was originally developed by Andi Gutmans and Zeev Suraski while they were students at the Technion - Israel Institute of Technology. They later founded a...

. The idea was received well by the PHP community, and more people started to get involved with the project. James Moore and Steph Fox were among the first to join in, contributing a great deal to PHP-GTK through their documentation efforts, and Frank Kromann - also from the PHP development team - supplied Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

 binaries for the project.

The first version of PHP-GTK was released in March 2001. More people began to get involved, and several extensions were contributed introducing new widgets, such as Scintilla
Scintilla (editing component)
Scintilla is a free library that provides text-editing functions, with an emphasis on advanced features for source code editing. SciTE , Notepad++ and Notepad2 are standalone editors based on Scintilla.-Features:...

 and GtkHTML. PHP-GTK 1.0 was released in October 2003 alongside several extensions — including a wrapper for libglade, which allowed the cross-platform Glade
Glade Interface Designer
Glade Interface Designer is a graphical user interface builder for GTK+, with additional components for GNOME. In its third version, Glade is programming language–independent, and does not produce code for events, but rather an XML file that is then used with an appropriate binding .Glade is...

 UI builder to be used in creating PHP-GTK applications.

Present

PHP-GTK was quickly adopted by the PHP community. Several applications were developed, and a small job market even emerged. Zmievski and Fox are still working hard on the project, with Fox now maintaining PHP-GTK for Windows.

Development is in full swing for the next major version of PHP-GTK. PHP-GTK 2 fully utilizes PHP 5's powerful object model support, and brings the improved portability of GTK 2.6 as well as its new set of widgets. The project also has some new extensions such as GtkSourceView, which provides a rich source editor widget, alongside some of the old favourites.

Documentation for PHP-GTK 2 is filling out rapidly. Several articles and tutorials have been written on the topic, and around half the classes have been fully documented. Scott Mattocks, an active member of the PHP-GTK documentation group, has also written a book on the subject of PHP-GTK programming.

Example



function pressed
{
echo "Hello again - The button was pressed!\n";
}

$window = new GtkWindow;
$button = new GtkButton('Click Me');

$window->set_title('Hello World!');
$window->connect_simple('destroy', array('Gtk', 'main_quit'));
$button->connect_simple('clicked', 'pressed');

$window->add($button);
$window->show_all;

Gtk::main;

?>


The sample PHP-GTK 2 program instantiates a GtkWindow widget with the title "Hello World!", containing a GtkButton labelled "Click Me." When the button is pressed, the message "Hello again - The button was pressed!" is displayed on the console via the callback
Callback (computer science)
In computer programming, a callback is a reference to executable code, or a piece of executable code, that is passed as an argument to other code. This allows a lower-level software layer to call a subroutine defined in a higher-level layer....

 pressed.

Deployment

Several tools have sprung up that assist the simple deployment of PHP-GTK applications. PHP compilers such as PriadoBlender and Roadsend PHP (Currently only compatible with PHP-GTK 1, while latest snapshot includes PHP-GTK 2) enable the compilation of applications written in PHP-GTK to a standalone binary executable. Alan Knowles' PECL
PHP Extension and Application Repository
The PHP Extension and Application Repository, or PEAR, is a repository of PHP software code. Stig S. Bakken founded the PEAR project in 1999 to promote the re-use of code that performs common functions. The project seeks to provide a structured library of code, maintain a system for distributing...

package, bcompiler, also allows compilation of PHP into bytecode to hide the source code.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK