Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

As you probably are aware, PHP is not only usable for web programming, but also desktop programming. It even has things such as GTK bindings.

Do you have any examples of places where PHP is actually used outside web programming for anything more than just very trivial programs? Do you know of any desktop program which uses PHP to some extent (e.g. as Python could be used in a C program)?

Note: I don't program in PHP myself, I'm just curious

share|improve this question
Related: stackoverflow.com/questions/40870/… – Maglob Feb 3 '11 at 19:21

closed as not constructive by gnat, MichaelT, MadKeithV, Jimmy Hoffa, Jalayn May 6 at 15:27

As it currently stands, this question is not a good fit for our Q&A; format. We expect answers to be supported by facts, references, or specific expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, see the FAQ for guidance.

7 Answers

up vote 4 down vote accepted

PHP makes a pretty good background scripting language. I use it a lot for running cron jobs. I have one that interfaces with a govt agency's servers a few times a day, sends and retrieves data, processeses it, and then adds it into our system. Whats nice is that I can reuse the classes used in the web app. Its not a desktop app, but its not exactly something you'd call trivial, and not a web app. I had another years ago that was an email bounce handler that ran 24x7 for several years, with only the occasional restart (usually due to the machine).

There's no technical reason that PHP cant be used for desktop apps. Like you say, there are bindings for that. But its hard to justify doing so when you compare PHP/GTK with the capabilities of a modern desktop IDE such as Delphi or Visual Studio.

share|improve this answer

At that point I would probably jump to ruby or python. Where I tend to use php is in places where I am going to reuse stuff I already built for the web for something else. The something else tends to be util and batch scripts. (I write a lot of my own tools)

share|improve this answer
I took over a project where, like several other answerers, there were some cron jobs/background stuff written in PHP. I've converted most of it to Python, partially out of personal bias, partially because it just seems more appropriate and readable. – Beekguk Mar 25 '11 at 16:12

I use PHP all the time to do quick and easy tasks that would take days in the equivalent Java code. I have cron jobs like @GrandmasterB, useful onetime scripts, and data collection scripts, all in PHP.

Where I draw the line is PHP-GTK. Just the syntax of OOP in PHP is hard, but with GTK its unbearable. I dabbed in it a few years ago and never touched it again due to the ugliness of the code (I can never read PHP-GTK code and understand it).

So in short:

  • CLI - All the time
  • GUI - Never
share|improve this answer
Indeed. Php-gtk is largely unavailable (not packaged in major distributions for years) because it's too cumbersome to use anyway. Sadly php-Tk and php-Qt went unmaintained. – mario Feb 3 '11 at 23:59

m0n0wall is a FreeBSD variant where the rc.d (FreeBSD's init.d for you Linux folks) shell scripts are replaced by PHP scripts.

One of the real drawbacks you will run into once you start to do more advanced PHP programming is the lack of any real multiprocessing capabilities (i.e. Threads).

There is pcntl_fork(), which works (wrote example some time ago), but it has the major the drawback that it doesn't work on Windows. One might also argue that using fork() is inferior to using threads, but that's a can of worms best left closed in this discussion :)

share|improve this answer
+1 for pointing out lack of threads support. – Jacek Prucia Mar 24 '11 at 10:30
For 99% of the people using PHP I would be very scared of them using threads. (Of course that also applies to Java). – Zachary K Mar 26 '11 at 17:01
Well, it's certainly true that PHP in general doesn't always attract the best&brightest in the programming world ... That's not a reason to exclude certain basic features ... I suspect that the lack of threading support has more to do with the lack of design and forethought that went in the language though, and that adding threading support after-the-fact would be very difficult (Look at the PHP6/Unicode fiasco for example). – Carpetsmoker Mar 27 '11 at 0:32

PHP for Android let's you build PHP applications on the Android OS.

share|improve this answer

I've used PHP to write a simple WebSocket server, then as a database synchronization tool (sync of X databases across the network(s) which was quite non-trivial), various small tools such as search/replace/find stuff in files/directories and I must add it behaves quite well in those areas.

share|improve this answer

I have used php as a scripting languages in an environment that I wanted to keep consistency. Since it was a large web-based application with thousands of lines in php, it would made more sense to write about a hundred more in php for scripts than introduce another language for just such a small factor.

Although some purists would disagree and prompt to use the best tool for the job.

The arguments provided by @Carpetsmoker are very valid. It was not designed to be used in a command line environment and sometimes this becomes obvious.

So my take: evaluate if what you need to do is small scale or not.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.