I have been pondering about this for a few days, and I'm surprised this hasn't been done yet or isn't very popular.
What I would like to see was a way to run a PHP application inside a desktop application. For example, the application would need its own mini webserver that doesn't handle requests, but allows PHP to be run.
Sometimes I have been set with tasks that clients demand coded in C# or .NET, and I think to myself 'I could have this done so much quicker if I could use PHP'.
Does anyone have any information on this subject? And FYI I do know PHP is meant to be a web programming language and is not meant to be run in a desktop application, but I'm intrigued :)
PHP-GTK hasn't had a new version since 2008, but it may suit your needs.
http://gtk.php.net/ is exactly what you want. You will be using an old GTK version, at least until a new php-gtk version is released (which is expected soon, according to the main page), but even that shouldn't be a big problem.
Also, see http://news.php.net/php.gtk.dev, it shows there is still activity on the project.
If you mean console (command-line) applications then by all means you can do that. I do it all the time, both on Windows and Linux. Obviously you will not have web-server related variables ($_GET and so on) but other than that you have full functionality of PHP.
See this for details.
PHP installations come with two executables, one for CGI (common gateway interface) and one for CLI (command line interface). Just set up PHP on your machine and use the correct php.exe.
If you mean applications with windows then, like others say, there are frameworks for this, but I doubt this is a good idea.
Well if you write a simple shell in .NET, you can drag a web browser object into the desktop app and simply show a webpage inside there, without the browser controls (back, home, etc).
This is a bit hackish, if you want a desktop app, code a desktop app, you'd be surprised how easy it is in C#.NET. And obviously the PHP needs to run somewhere, either on an external website or a local web server (ex: XAMP)
I've done a couple of applications for a customer using miniPHP Studio for exactly the same reasons. Both me and the customer were happy about the result. Might take some time to get used to it, but it has a kind of a debugger built into the IDE and, being based on Winbinder, you can use its forum to pick up more code samples.
Stuff I definitely found out works well with it: PDO, MySQL, SQLite, cURL, mbsting, mhash, mcrypt, bz2, ADODb (after modifications), running external programs. Stuff I never managed to make behave: FreePDF, having the input fields accept Unicode characters.
For the future (read: as soon as I find some free time) I'm gonna take a look at Titanium. This one definitely looks as being actively developed and on a path upwards.
PHP Nightrain is a packager written in Python for the PHP Programming Language. Using this tool you can convert your PHP/HTML/CSS/Javascript application to a Native Desktop Application. Currently, PHP Nightrain supports the Windows, Mac (OS X) and the Linux operating systems.
Features:
PHP 5 Pre-compiled
Option to use your own PHP
GUI rendering your PHP/HTML Web Application
Set custom width and height
Start application Maximized if required
Start application Fullscreen if required
Window Title changes as the value of the title tag changes
executable for Windows
executable for Mac
.app file for Mac
executable for Linux
https://github.com/naetech/nightrain
http://www.naetech.com/php-nightrain
Related
I have developed a PHP web application, but a client insists on a real Windows application, since he doesn't like running the software inside a browser.
Are there any solutions for this, any compilers to turn a web project into a Windows exe ?
I have looked at Phc-Win , but that seems more suited for small command line utils, not for entire web-applications...
UPDATE:
just found this myself, both look quite promising...
http://www.zzee.com/phpexe/
http://www.exeoutput.com/index.php
There's no tool for this, short of a simple wrapper app that embeds a browser inside an otherwise normal application window. Your PHP app would have to be completely re-written to include ALL of the overhead code necessary to build a GUI - basically all the 'display' stuff that a browser does automatically, would have to added to your app.
Well some of you did not google good enough:
http://www.appcelerator.com/products/titanium-cross-platform-application-development/
Supports most of the "web-languages" to write native Applications.
Tutorial Reference for Appcelerator: http://appceleratortitanium.com/tutorials/3-appcelerator-titanium-tutorial-beginners.html
Quote:
"Q: What languages can I use to make desktop apps?
A: Javascript, PHP, Python, Ruby, HTML, HTML5, and CSS."
Not exactly what you are looking for: http://www.roadsend.co/home/index.php?pageID=compiler
You may look into "HipHop" (made by Facebook): Converts PHP to compileable C++-
There's a tool for this. :-) I never used it but you can try this: Winbinder.
It is simple to compile your PHP source code into an executable. Facebook released a compiler for PHP in early-2010, called HipHop, which aims to create C++. You could then compile this code, for example using gcc, to machine-code.
The more difficult point for a complex Web-App like yours is the user interface. When compiling the way I described above, the application can be run from command line - this might work for simple tasks, but not, if your application returns HTML.
One possibility to solve this problem is PHP-GTK. PHP-GTK is a API for GTK (the graphical user interface used by Linux Ubuntu by default), written in PHP. Using this solution would have to read some documentation about this API, and you would need to rewrite some parts of your program, but it would probably be the most beautiful solution, because it would create a "native" experience.
Another possible solution could involve Adobe AIR, which lets your create programs for the desktop, using HTML, CSS and JavaScript, but I don't know if and how this would work together with your compiled PHP.
Please also note that it isn't absolutely necessary to compile your PHP for it to run on the client's computer; You could also ship the PHP-interperter right with your (uncompiled) PHP-script. Of course, compiling brings benefits, such as faster execution of the program.
-- André
I'm choosing between these two languages, in contrast to another question here. My program going to be set of scripts checking files, free space, checking that apps are running etc. and writing information to database. Then PHP web page will show results.
Python have more examples of winapi calls (at least at StackOverflow) and more attractive to learn and use in different areas of programming, but I didn't use it before. With PHP I have small experience and I will be using it for results web page anyway.
PHP seems to be easier to install on network (to use one network installation for many workstations). Both languages can work with COM objects (I will need ADO).
Scripts will be small, not complex, but their number will grow.
Can someone with experience in similar tasks advise on choice between these two?
Don't shrink from using a language just because you haven't used it before. Learning a new language is one of ways to expand your overall capabilities as a programmer. True, you won't be as productive with it at first but learning how the language tackles common problems (manipulation of data structures, creation and lifetime of objects, etc.) will teach you new ways to think about computing.
That said, I would suggest you use the ActiveState version of Python (http://www.activestate.com/). It has the Windows integration included. I'm not sure about network install with Python. I've installed it across a net by running a remote desktop of the target and running the installer. Windows wants things registered in the registry so running a language is not like running an .exe sitting on a remote file share.
I asked question first time as anonymous so have no other option to reply now except to write an answer.
Thank you verisimilidude for ActivePython advice!
Installed ActivePython at home, reading Dive into Python 3.
Installed RadPHP XE at work (company bought it).
So for work it will be PHP. For me, if have free time (and may be for kids, when grew and if interested) it will be Python.
As someone who uses both on a regular basis, I tend toward using python for windows scripting and php for web apps. It's mostly just my preference, but I think they're each ideally suited toward different things. I love using Python in windows, it is really versatile.
a ) python is a nice alternative because you can generate an executable, otherwise (running as script) php is more suitable because it does not required an installation.
b ) try to not to connect directly to the database. Instead, you can create a web page then the clients can connect to it instead to do a direct connection to the database.
for example in php (in the client)
$fp=fopen("http://192.168.0.200/update?id=mymachine&value=200","r");
fclose($fp);
ps: For api calls, both (php and python) can do the same. Thought, for php and Windows Vista (and higher) exist some restriction when you are running it as a apache-module and apache is running as a service but i don't think it is the case.
Is there anything I can use to have PHP execute in a self contained environment without having to install server software?
haven't learned other languages :-(
I wanted to write a simple php/XML webapp that can be used on a desktop machine with no admin rights. It's for daily data entry stuff myself and others have to do when certain tasks are completed. Its a work machine and security is super high so can't have the details traversing the internet to my hosting.
Any suggestions?
XAMPP Portable might be what you are looking for. You don't need admin rights to run it.
http://portableapps.com/apps/development/xampp
Regardless of what language you use, in order to have a webapp, you need a web server of some sort, to listen to requests and send a response back (even if it's just listening to localhost). It is possible to run php from a command line without a server, but I don't know if you want to convert your application to a command line one.
Assuming you're using Windows, there are solutions for compiling PHP into an exe file (a quick google search found Phc-win, for example). However, I've never actually done this myself so this be sure to fully investigate what this would entail! You'd most definitely need to rewrite your views to use some way of creating actual dialogs in Windows (ie. WinBinder, or wbObjects).
(Of course, if you wanted to convert it to a desktop app the best solution is to actually use a language meant for desktop development, but if you only know PHP and don't want to spend the time learning something else, this could suffice, I guess.)
I have an existing CakePHP that runs on a LAMP environment and need to install it on a USB drive for mass public distribution.
There are a few requirements:
Protect the source code
No installation required
Windows support essential
MAC & Linux would be a bonus
Must run offline, without Internet connection
Ability to sync with server for data transfer and updates
I have conducted a large amount of research into the options and am keen to learn what other developers think.
Potential solutions:
- Flash / XML
- Adobe AIR app
- USB webserver (Server2Go, Portable Apps XAMPP)
Has anyone used any of the above, any comments would be greatly appreciated.
Thanks
Similar thread here :
Portable USB Webserver
If you ask me, XAMPP should do, because it offers a "plain unzip" version. There's lots of variety out there - Bitnami also offers a nice bunch of stacks, although they may not be good for this particular task.
To keep the same scripts in both Windows and Linux, you could consider using UnxUtils which is a port of all common Linux commands. This will be very handy if you are good at Linux bash shell scripting but not good at Windows batch files.
Protecting the source code is a bit troublesome. Do you really, really need to do so? Because there's a ton of great open source code out there which already does practically everything in most common business domains - sourceforge.net.
And if someone's taking your code and calling it their own, you can just name them on the internet if you can prove it. That itself will be bad publicity for them. That said, I obviously don't know your specific need. So that is just my opinion.
You will have problems with this, no matter how you go about it. Each step is a little more unusual it seems.
You'll need to use a source code obfuscator to protect your source. I recommend the one by Zend, not from experience, but because Zend makes awesome products. Never used a source protector myself.
You'll need three custom LAMP/MAMP/XAMP installs, one for each target OS. They should point to a directory that is shared on the USB drive. Make sure you configure them to use an unprotected port, otherwise the user will need admin privileges to run the server software. And getting the server stuff up and running will likely result in a few hiccups as well.
I would actually recommend finding something that will allow you to distribute a binary, or something like an AIR app that is intended for this type of distribution. You may have to rewrite lots of code, but it'll be easier to fix than all the niggling little install errors you'll see on the client end. To package scripts into binaries without rewriting stuff, check out http://www.scriptol.com/apollo.php and similar products.
But I'd suggest you make a standalone app in adobe air that will sync with your server (maybe even some google gears integration, to have it function offline). Don't try to force a PHP app into this distribution model, it'll create nightmarish problems.
This is what I used to run a CakePHP app from a DVD. Worked on USB too (while I was still developing it).
http://www.server2go-web.de/
Server2Go is a Webserver that runs out of the box without any installation and on write protected media. This means that web applications based on Server2Go can be used directly from cdrom, a usb stick or from any folder on a hard disk without the hassle of configuring Apache, PHP or MySQL.
Server2Go allows you to create a standalone working web site or PHP application on a CD-ROM.
It's really nice.
You can use MAMP for Mac, you'll just need to edit the config to properly point the sites directory.
however you would have the problem that the mysql db would not necessarily work with windows. if you switched the db to sqlite, you could sync the sqlite db file fairly easily.
XAMPP would work for the windows side
sorry dont know about the linux side.
Out there is a CakePHP InstaWeb Server
http://bakery.cakephp.org/articles/view/the-cakephp-instaweb-webserver
that runs on python and doesn't need an installation. This plus some additional goodies should get you already half the way.
We have an existing windows desktop app written in C# 6 that uses an MDB MS access database for its storage. I need to write a web interface that can read that php webpage and maybe write to it later on.
This web interface will be included with our current installer for the application or as a simple addon. The user should only have to click start server and it should just work serving the php pages from the installation directory.
I was playing with gwan, nginx, quickphp. Only the last one seems simple enough to work.
So my question is what do or would you use to achieve this? Are there alternatives to quickPHP?
Distribution. I'd also like to have something we can include in the installer. I dont want the user to have to do and download any additional apps.
I know you said PHP, you also mentioned your app is written in C#.
You might want to take a look at aspnetserve if you are willing to write the web part in .NET. It might be possible to use PHP with it, but I don't know.
Either way I have found it very useful in several projects.
If you can live with other types of server side scripting than php, Microsoft's Cassini server looks like potentially a very good match (.net based, source available, small, ...).
Oddly enough it's hard to find a "canonical" url for it but Googling or searching here on SO brings back plenty of links.
Edit: an at first sight surprising feature may be that out of the box Cassini only seems to listen to localhost (127.0.0.1). However, as explained here,
Cassini only listens to localhost requests (for security reasons) -- it
uses IPAddress.Loopback in the code. You can find the code in Server.cs and
you can change it to IPAddress.Any to enable access from other machines. Of
course, you'd be opening up the port for outside access, so you need to be
aware of the security implications.
Or go with UltiDev Cassini
EasyPHP
Lampp
For a light-light-weight server without installation you can look at nanoweb portable. I am not sure how performant it is though.
Are there alternatives to quickPHP? The user should only have to click start server and it should just work serving the php pages from the installation directory.
G-WAN works like this (zero-configuration): scripts and "edit & play".
And G-WAN v3.10+ supports C#, Java and PHP scripts (all natively).