Helping ordinary people create extraordinary websites!

Building Desktop Applications in PHP

By Akash Mehta
2008-02-09

Fundamentals

Now, desktop application development is an entirely different cup of tea. It’s not what you’re used to: you’re used to being input-driven, but desktop apps are event driven (Delphi for PHP is the best of both worlds). As a result, before you start developing desktop applications, you’ll have to step back for a moment and examine the differences.

As a web developer, you’re familiar with the basics of web scripting. Client makes request to server, server runs your PHP code through PHP compiler/interpreter, output is sent to client etc. etc. Your entire request has finished very quickly; possibly in less than a second. The user didn’t do anything in between; the data for the request (cookie data, get / post values, server and environment variables etc.) was all set once before your code was run. When executing your script, PHP went from top to bottom, ending at the last line of code in your PHP file. Once it’s finished, the request is gone; the process finished, possibly even the thread killed.

Desktop applications, on the other hand, are nothing like this. Now that we have full-on JS-heavy web applications, you should have a basic understanding of how desktop application development works – think of it like a web application written entirely in JavaScript. It’s heavily event driven, with functions for different events such as a button click or a mouse move, and it keeps going without executing any code. In desktop applications, you first draw the window using some basic UI code, and then wait – just wait. You have to give up a bit of control to the operating system – for example, if you want a menu, you (typically) tell the operating system to draw a menu and to bind some of your functions to the menu items, then let it take care of the rest. It takes quite a while to get used to, but soon enough you’ll get the hang of it, and be building fantastic desktop applications in no time.

Of course, as your applications are written in PHP, you can also reuse all your existing PHP code - well, almost all (HTML output won't exactly help). As a result, once you understand the basics of desktop development, you can be building powerful desktop applications in no time - you could even integrate with your existing web application!





Tutorial pages:
 6 Votes

You might also want to check these out:


Leave a Comment on "Building Desktop Applications in PHP"
You must be logged in to post a comment.

Link to This Tutorial Page!


GET OUR NEWSLETTERS