1 / 20

Client-side Applications with PHP

Client-side Applications with PHP. Andrei Zmievski & Frank M. Kromann. Track: PHP Conference Date: Friday, July 27 Time: 3:45pm – 4:30pm Location: Fairbanks C&D. PHP a General Scripting Language. HTML-embeded scripting language Cross platform Rich on functions and extensions

keaira
Download Presentation

Client-side Applications with PHP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Client-side Applications with PHP Andrei Zmievski & Frank M. Kromann Track: PHP Conference Date: Friday, July 27 Time: 3:45pm – 4:30pm Location: Fairbanks C&D

  2. PHP a General Scripting Language • HTML-embeded scripting language • Cross platform • Rich on functions and extensions • Also used for shell scripts

  3. Adding a GUI to PHP • With a GUI it is possible to write client side applications and tools. • PHP becomes event driven.

  4. What is GTK • GTK+A multi platform toolkit for creating graphical user interfaces. • GlibProvides useful data types, type convertsions, macros, string utilites etc. • GDKA wrapper for low-level windowing functions. • GTKAn advanced widget set.

  5. Automated code generation • The source code for the php-gtk extension is generated from a set of definition files. • 600 constant definitions • 95 Objects • 970 Methods

  6. Web applications • Request driven • Procedural execution • Tight integration with the web server

  7. Event driven applications • Setup main window • Create functions • Connect functions to events • Start the main loop

  8. Loading the extension • PHP-GTK is not a built-in extension <?php // this file is used to make sure the gtk-extension is loaded. if (!extension_loaded("gtk")) { if (strtoupper(substr(PHP_OS, 0,3) == "WIN")) dl("php_gtk.dll"); else dl("php_gtk.so"); } ?>

  9. Creating Gtk objects • The syntax for creating an object is: • $window = &new GtkWindow(); • With globals in functions use: • $GLOBALS[”window”] = &new GtkHBox()

  10. Hello World #!/cygdrive/d/php4/php_win <?php require "gtk.inc"; $window_width = 500; $window_height = 200; $window_xpos = (Gdk::screen_width() - $window_width) / 2; $window_ypos = (Gdk::screen_height() - $window_height) / 2; $main_window = &new GtkWindow(); $main_window->connect('destroy', 'destroy'); $main_window->set_policy(TRUE, TRUE, FALSE); $main_window->set_title("Gtk+ Hello World"); $main_window->set_uposition($window_xpos, $window_ypos); $main_window->set_usize($window_width, $window_height); $main_window->show_all(); Gtk::main(); ?>

  11. Add a close-button … $main_window->set_usize($window_width, $window_height); $close_button = &new GtkButton("Close"); $close_button->connect('clicked', 'destroy'); $close_button->show(); $main_window->add($close_button); $main_window->show_all(); …

  12. Connecting Signals • Signals are used to connect user actions and system events with php-functions. • Examples: • ’clicked’ signals on buttons. • ’destroy’ signals on windows.

  13. Callback function • Names are case-insensitive • Names are passed as strings (lowercase) • The object emitting the signal is the first parameter, can be changed with the connect_object() method. • Additional parameters can be added

  14. Popup Messagebox() $main_window = &new GtkWindow(); $main_window->set_position(GTK_WIN_POS_CENTER); $main_window->connect('destroy', 'destroy'); $main_window->set_policy(TRUE, TRUE, FALSE); $main_window->set_title("Gtk+ Hello World"); $main_window->set_usize($window_width, $window_height); function Confirm_Quit($calling_button) { if (MessageBox("Do you realy want to quit ?", "System Message", MB_YES | MB_NO) == MB_YES) destroy(); } $close_button = &new GtkButton("Close"); $close_button->connect('clicked', 'confirm_quit'); $close_button->show(); $main_window->add($close_button); $main_window->show_all(); Gtk::main();

  15. The gtk.php sample • Shows basic and advanced features • How to use Gtk objects • GtkWindow, GtkButton, GtkClist • GtkCursor, GtkCtree, GtkEntry, GtkLabel • GtkPixmap, GtkRadioButton, GtkTooltips

  16. Database Manager • Manage local or remote DBMS • View status of databases • Start and stop databases • Demo

  17. DB Query Tool • A simple SQL tool • Executing SQL Statements • Exporting data • Cross platform • Support for mulitple databases • Demo

  18. Related technologies • libGlade • …

  19. Future Development • Adding support for aditional functions • Compiling php-gtk as a built-in ext. • Documentation

  20. More Information • http://gtk.php.net • http://www.gtk.org • http://josefine.ben.tuwien.ac.at/~mfischer/articles/article-php-gtk.html

More Related