Bright Hub
 
Matthew Casperson's Hubfolio

Deploying a PHP-GTK application with NSIS

Article by Matthew Casperson (4,883 pts )
Published on Nov 2, 2009

PHP-GTK allows you to take PHP to the desktop. This tutorial shows you how to package and distribute a PHP-GTK application.

Introduction

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.

Step 1 - Get PHP-GTK

Download and extract the PHP-GET Windows Binary Pack from here. This pack includes the PHP runtime and the GTK

Step 2 - Create a hello world application

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();

?>

Step 3 - Get NSIS

NSIS stands for Nullsoft Scriptable Install System. It is used to create executable setup packages. Download and install a copy from here.

Step 4 - Get HM NIS Edit

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.

Step 5 - Configure HM NIS Editor

In the HM NIS Editor click View->Options. Set the location of the compiler to the makensis.exe file from the NSIS directory.

PHP-GTK Deployment ScreenshotPHP-GTK Deployment Screenshot

Step 6 - Create a new script

Click File->New script from Wizard. This starts the script NSIS Script Wizard.

PHP-GTK Deployment Screenshot

Specify the name, version, publisher and website for your application.

PHP-GTK Deployment Screenshot

The next screen allows you to specify the setup icon, language, file name, GUI style and compression type. The defaults here are all OK.

PHP-GTK Deployment Screenshot

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.

PHP-GTK Deployment Screenshot

This screen is where you specify what files are going to be included in the deployment executable.

PHP-GTK Deployment Screenshot

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.

PHP-GTK Deployment Screenshot

Search More About:

Follow Matthew Casperson
Receive weekly updates from Matthew Casperson
 
Bright Hub - Science & Technology Articles, Buyer's Guides, How-To Tips and Software Reviews
About Bright Hub | Contact Us | Advertise with Us | Become a Writer | RSS | Site Map | Terms of Use | Privacy Policy | Copyright Policy
©2009 Bright Hub Inc. All rights reserved. Page copy protected against web site content infringement by Copyscape