can we make desktop application with php??

Recommended Answers

All 5 Replies

There are some solutions out there that claim to be able to do this, but i've heard from others that they are all very buggy, and they're not worth investing time into. You would most likely be better off using another language like Python, Java, or another language that natively supports this.

Member Avatar for diafol

You can create a php desktop application with php-gtk. However, it's really awkward and hasn't been updated for some time.

http://gtk.php.net/

As pixelsoul states, PHP is probably not your best bet to create a desktop app. Perhaps look at .NET solutions, such as VB.NET or C#.NET

All of these have their advantages and disadvantages. Choose the best tool for the job, which probably won't be PHP in this case.

Feel welcome to correct me, but I'm going to say no, it's not possible to create a desktop application using PHP. It's essentially a server-side scripting language, intended for use with web servers.

Why would you want to develop apps in PHP for the desktop when there are so many better tools for the task? If any PHP compiler for desktop exists it's likely to be horribly inefficient. PHP's strengths lie server-side.

Ah, it looks like I'm wrong...
http://duckduckgo.com/?q=PHP+desktop+application

But I still can't see the need. Perhaps someone would like to explain :-)

I tried mini PHP Studio, one of the programs designed to do desktop PHP. It worked but it wasn't really a serious development environment that you'd want to invest a lot of effort into.

If your real question is "can I use my PHP coding skills for a desktop app" then I think that the answer is a qualified yes. I've been using PHP for the web and Autoit for the desktop for quite some time and it's pretty easy to go back and forth. I think that the developers of Autoit had quite a bit of PHP experience so there is a lot of similarity.

Here is a simplistic PHP example:

<?php
/*
     A very simple PHP example intended to compare to an equivalent
     Autoit program.
*/     

     echo "<br>A simple PHP example"; 

     $a   = 5 + 1;

     $b   = $a + 1;

     echo "<br>The result is ".$b;

     echo "<br>The End";     

?>

Here is some equivalent Autoit code:

    ;  A very simple Autoit example intended to compare to an
    ;  equivalent PHP program.


         MsgBox (0,"Example","A simple AUTOIT example");

         $a   = 5 + 1;

         $b   = $a + 1;

         MsgBox (0,"Example",@CRLF & "The result is " & $b & @CRLF & "The End");

I know this is really simplistic but the point is that the processing code is quite similar. Since there isn't a default output window in Autoit (equivalent to the browser window in PHP), I used MsgBox which pops up a small message window. I could have opened a window for it but I was trying to keep this really simple. Unlike PHP, you don't need a semi-colon at the end of every line but I put them in here to show that you can make the code quite similar if you want to.

You don't have to predefine variables before using them in either case (but you can force it). The built-in functions aren't exactly the same but they are similar. For example, to make a string upper case, PHP uses StringToUpper while Autoit uses StringUpper. Both languagues have similar Include capabilities as well as similar ability to use User Functions.

The basic Autoit package has quite a number of standard Functions that you can include in your programs for working in the Windows environment, to manipulate variables and strings and so forth. It also has a large number of User Defined Functions (UDFs) that extend the Autoit capabilities even further. One example is the Internet Explorer UDF that uses a COM interface to the IE facilities in Windows. This is very useful for screen scraping and browser automation. There are also UDF's that provide interfaces to MySQL and SQlite. Autoit programs can be 'compiled' into EXEs. The Autoit intrepreter is automatically included into the compiled program. Thus, compiled Autoit programs aren't tiny or lightning fast but if that is a requirement then you should be using Aseembler or C.

Autoit has a pretty active user community. On the website, there are lots of code examples and UDFs of all types. I found that Autoit was a pretty easy way to take my PHP coding experience and use a lot of that to start building desktop programs.

Member Avatar for diafol

mini PHP Studio only available for Mac at the moment.

Using niche languages is great, but you need to consider the pros and cons. Active third party or community contributions will be considerably less / fewer with these. Whereas 'mature', mainstream languages will have gazillions of resources and help forums. Another pro for mainstream is the ability to collaborate easily or hand-off a project. Don't let me put you off though, if you find something good, let us know.

//Just looked at AutoIt - looks interesting - code looks more like classic VB to me though.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.