PHP-GTK allows you to take PHP to the desktop. This tutorial shows you how to package and distribute a PHP-GTK application.
PHP-GTK is a project that binds the GTK desktop library. Unlike other solutions like Appceletartor Titanium, which create web applications that are distributed like a desktop application, PHP-GTK allows PHP developers to create native desktop applications utilizing the GTK platform.
One of the issues with PHP-GTK is distributing the final application. This tutorial steps you through the process of creating a setup package for a simple PHP-GTK application with NSIS and HM NIS Edit.
Download and extract the PHP-GET Windows Binary Pack from here. This pack includes the PHP runtime and the GTK
Create a file called helloworld.php in the same directory where you extracted the PHP-GTK files. The hello world demo code comes from this page here.
<?php
if (!class_exists('gtk')) {
die("Please load the php-gtk2 module in your php.ini\r\n");
}
$wnd = new GtkWindow();
$wnd->set_title('Hello world');
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));
$lblHello = new GtkLabel("Just wanted to say\r\n'Hello world!'");
$wnd->add($lblHello);
$wnd->show_all();
Gtk::main();
?>
NSIS stands for Nullsoft Scriptable Install System. It is used to create executable setup packages. Download and install a copy from here.
HM NIS Edit is a free tool that can be used to create the scripts used by NSIS to create a deployment package. Download and install a copy from here.
In the HM NIS Editor click View->Options. Set the location of the compiler to the makensis.exe file from the NSIS directory.
Click File->New script from Wizard. This starts the script NSIS Script Wizard.
Specify the name, version, publisher and website for your application.
The next screen allows you to specify the setup icon, language, file name, GUI style and compression type. The defaults here are all OK.
This screen allows you to define the default installation directory and specify the license file. Here I have just used the PHP-GTK readme.txt file, but you will probably want to specify your own license file.
This screen is where you specify what files are going to be included in the deployment executable.
Two dummy files are listed. Select them and click the black cross icon to remove them. Now click the icon that looks like a folder tree. This allows you to add all the files and subfolders from a specified folder.