PHP-GTK2 Newsletter
|
Sample Code 28: How to distribute your PHP - GTK applications - Method 1? |
| Written by kksou | ||||||
| Thursday, 21 September 2006 | ||||||
|
Problem Suppose you have developed a GTK-PHP2 applications, and you would like to deploy this over 100+ sites within your company (or maybe school campus). The codes are updated very frequently. And each update requires you to propagate the changes throughout the 100+ sites. What are your options? Solution There are many different options for deployment of php-gtk applications. Here we present one method. Please take a look first at the sample code below - yes, 3 lines only! Run the code, and you should get the output as shown below. I'll elaborate more in the Explanation section. Sample Code
Explanation As you might have guessed, this method puts the bulk of the codes at the server side, in this case:
<?php
function hello_world() {
$window = new GtkWindow();
$window->set_size_request(400, 100);
$window->modify_bg(Gtk::STATE_NORMAL, GdkColor::parse('#CCFF99'));
$window->connect_simple('destroy', array('Gtk','main_quit'));
$label = new GtkLabel('hello world from remote server!');
$window->add($label);
$window->show_all();
Gtk::main();
}
?>
The sample code simply includes the function above and calls the function As documented in the PHP manual, "if 'URL fopen wrappers' are enabled in PHP (which they are in the default configuration), you can specify the file to be included using a URL instead of a local pathname." And this is exactly what we using here. By storing the main codes on your server, you only need to maintain one single copy of your code. There is no need to update any of the 100+ sites because they will always get the most updated copy direct from your server with the Of course, this method is based on the following assumptions:
Note
DO NOT use this method if security is your key concern.
The key advantage of this method is ease of maintenance and updating of your php-gtk application over large number of sites. |
||||||
| < Prev | Next > |
|---|



