-
-
Notifications
You must be signed in to change notification settings - Fork 574
Knowledge Base
Table of Contents generated with DocToc
- Hello World!
- How does PHP Desktop work?
- Which browser engine to choose?
- Should I use PHP 5.4 or newer?
- PHP interpreter & extensions
- PHP on Linux doesn't support XXX extension
- Useful tools
- How do I protect PHP sources in the "www" directory?
- Settings
- Application name
- Application details
- Application installer
- How to use SQLite?
- Can I use MySQL?
- Can I use PHP Desktop in a commercial closed sourced project?
- Feature X works in Google Chrome, but doesn't work in PHP Desktop Chrome
- Url rewriting support
- How do I call external programs or commands asynchronously in background without waiting for them to end?
- Problem running Drupal app due to REQUEST_URI env variable not containing QUERY_STRING
- Problem running PHP script
- Error 500: Internal Server Error. CGI program sent malformed or too big (>16384 bytes) HTTP headers
- Error 500: Internal Server Error. Cannot spawn CGI process [C:\Documents and Settings...\www\index.php]: No such device or address
- Error when application is placed in a path that contains unicode characters
- Black/White application screen
- How can I access files outside the "www" directory?
- mail() function doesn't work
- Flash works in Google Chrome, but not in PHP Desktop
- Can the www/ directory be encrypted and embedded in the exe file?
- How can I make phpdesktop binaries smaller?
- How do I read/write to Windows Registry?
- How to call functions from a DLL file?
- How to get a unique computer identifier?
- How to capture Audio and Video in HTML5?
- HTML5 Persistent Storage doesn't work (local storage, indexed DB, web sql)
- Audio and video support in PHP Desktop Chrome
- How to prevent users from browsing app outside the phpdesktop executable?
- What are the disadvantages of using PHP Desktop over Java or C++?
- Deployment issues
- Problems with cache
- What are other projects similar to PHP Desktop?
- Download the phpdesktop zip file and extract it
- Run the "phpdesktop-chrome.exe" executable
- What you see in application window is the output generated by PHP scripts in the www/ directory. PHP Desktop comes by default with some PHP scripts that test various features.
- When you're done playing with the default scripts clear the www/ directory and copy your own PHP scripts. If you're using a PHP framework then see the PHP frameworks support wiki page that provides step by step instructions for configuring many popular frameworks.
First, a Mongoose web server is started. It is pointed to listen at http://127.0.0.1:54007/
(54007 is some random port assigned). Its document root is set to the "www/" directory. Next, an embedded web browser control (Internet Explorer or Chrome embedded) is initialized in application's window and navigated to the location at which web server is listening. This browser does not have any Back/Forward buttons or other visible controls that would identify it as a web browser. It is not required for the Google Chrome browser to be installed on user's computer, as it is embedded in phpdesktop binaries with no external dependencies.
Internet Explorer (abbreviated MSIE) gives you smaller binaries, but you do not know the version of Internet Explorer that will be installed on user's computer. Incompatibilities between different IE versions can be troublesome. A good HTML5 support is only available since IE 9. It is not guaranteed that the version of Internet Explorer control embedded in application will be the same as the version of Internet Explorer installed on a computer. For example on Windows 7 SP1 with Internet Explorer 8 installed navigator.userAgent shows "MSIE 7.0".
Chrome binaries take more space, but what you get is a great HTML5 support. You also get certainty that your application will always look and work the same on all computers, no matter what operating system or service packs are installed on user's machine. This is because the Chrome browser is embedded inside phpdesktop binaries.
PHP 5.4 series is the last versions to support Windows XP/2003. Spawning of the PHP CGI process will fail in PHP 5.5 series on Windows XP. If you want to support XP use the PHP 5.4 series. Read the PHP 5.5 migration docs on the php.net website.
Windows XP still has 23.87% usage share (as of September 2014) on Desktop. That's quite a large user base. So most probably you want to use PHP 5.4, so that you can support this OS. For the most recent OS usage share statistics see the Usage share of operatings systems on the wikipedia.org website.
If you would like to update the PHP version that comes with phpdesktop, download the latest PHP release from windows.php.net and replace phpdesktop's php/ directory with the one you've downloaded. Here are complete steps for doing so:
- Download new PHP version, you must choose PHP binary marked as "x86" and "NTS" (non thread safe): http://windows.php.net/download/
- Backup phpdesktop/php/php.ini file
- Delete phpdesktop/php/* files and subdirs
- Extract the new php version you've just downloaded, in the phpdesktop/php/ direcotry
- Copy the backuped php.ini file back to the phpdesktop/php/ directory
The php.ini file included with phpdesktop has some useful settings enabled that can for example help debug possible issues with phpdesktop, but it is not mandatory to copy it, you can as well use the php.ini that comes with the new php version.
You can replace the PHP version that comes with PHP Desktop with any version you like. Note however that PHP Desktop communicates with PHP through the CGI interface and thus the PHP binary must support that interface, not any binary will work.
The PHP executable shipped with PHP Desktop on Linux only has a few extensions enabled by default. You can enable more extensions by building PHP from sources with the build-php-with-ext.sh
script that comes with PHP Desktop sources on Linux. Checkout the linux**
branch from git repository and you will find it in root directory. In that file you will find comments explaining how things work and how to enable more extensions.
Alternatively you can find existing PHP binaries on your system. Or search for "php-cgi" or "php7-cgi" or packages with similar names with your OS package manager and install it. For example with the sudo find / -name php-cgi
command you can search your whole filesystem for "php-cgi" binary already installed somewhere. On my Ububntu it found these:
/usr/bin/php-cgi
/etc/alternatives/php-cgi
/var/lib/dpkg/alternatives/php-cgi
So I've executed:
/etc/alternatives/php-cgi -i > phpinfo.html
google-chrome phpinfo.html
To check what version of PHP that was and what extensions it has enabled by default. Turns out it has lots of extensions enabled. To use that binary with PHP Desktop you have to copy it to the phpdesktop directory and and point to it by editing settings.json "cgi_interpreter" option.
- NirCmd, do useful tasks in background - http://www.nirsoft.net/utils/nircmd.html
- Inno Setup, create app installer for Windows - https://en.wikipedia.org/wiki/Inno_Setup
- AppImage, wrap application in a single file, easy distribution on Linux - https://appimage.org/
- PHPMailer, send emails without smtp server - https://github.com/PHPMailer/PHPMailer
- ResourceHacker, edit icon embedded in exe - http://www.angusj.com/resourcehacker/
- Chrome Devtools Protocol client for PHP - https://github.com/jakubkulhan/chrome-devtools-protocol
- NSSM, the Non-Sucking Service Manager - https://github.com/kirillkovalenko/nssm
You can load custom php extensions, thus you can use many of the available php encoders such as:
- Open source
- BLENC encoder - a PECL extension. Supports PHP 5.3 / 5.4 / 5.5 / 5.6.
- bcompiler - a PECL extension. Provides good protection by compiling PHP to bytecode. Unfortunately supports only PHP 5.3 or lower.
- Free
- ColdevProLayer - supports PHP 5.4, 5.5, 5.6, 7.0. The demo application bundle (testing_mod_php.rar) comes with PHP Desktop and PHP 7 and works out of the box. All downloads including extensions for other PHP versions are available here.
- PHTML Encoder - standard version is free. Supports PHP versions up to 5.6. Extension is available only for Thread Safe version of PHP. PHP Desktop bundles Non Thread Safe version of PHP by default, so it is required to update PHP binaries.
- PHP Protect - only obfuscates source code
- Commercial
- Ion Cube
- Zend Guard
- Source Guardian
- Nu-Coder
- CodeLock - a cheap one
See also:
- Enigma Virtual Box - for Windows only. Creates a single executable and hides files in memory.
- AppImage - for Linux only. Create a single executable for all Linux distributions.
See these wiki pages: Settings, Chrome settings, MSIE settings.
Rename the "phpdesktop-chrome.exe" executable to whatever name your application should have.
Apart from changing the name of the executable file, you may also want to change application details embedded in the executable. See what these are by clicking on file properties and selecting the "Details" tab. Some of these details may be displayed to user when running application (by OS alert or firewall), so it's best to customize it to avoid user confusion (user being informed by OS that he is running "PHP Desktop", when in fact he downloaded application named "XXX").
Here are the steps to modify application details:
- Download Resource Hacker and run it.
- From the "File" menu select "Open" and navigate through drive to find "phpdesktop-chrome.exe" (or whatever the name of your executable is).
- On the left side a tree control will appear. Expand "/Version Info/1/1033" and change the strings: "FileDescription", "FileVersion" and others.
- Save it.
PHP Desktop doesn't provide a single executable file, but that shouldn't be a concern. Most of the software is distributed in a form of an installer and we recommend to go this way. Try one of these to create an installer for your application:
- Squirrel Windows - An installation and update framework (auto updater) for Windows desktop apps
- Inno Setup + Inno Script Studio (see also ISTool).
- NSIS installer + HM NSIS Edit.
Details on how Auto Updater should work see this post: https://groups.google.com/d/msg/phpdesktop/CfZqiI3eMPY/2LNHbhkxumgJ
See the Using SQLite wiki page.
MySQL is not easily portable. It requires a system service to run in the background. It needs to be installed on user's machine. You could embed a mysql installer in your application installer, but there are some legal issues in doing so. Mysql is licensed under the GPL license, so you can only embed it in open source projects. If you have a commercial closed source project and would like to distribute mysql along with your app installer, then you would have to buy a commercial license for mysql. There is no clear price presented on the mysql website. When you try to google "mysql commercial license cost" it doesn't look too pretty. The costs seem to be per installed server or they want a percentage of the price of your product.
The beauty of SQLite is that it's portable, requires only a php extension to be loaded and it's totally free. It is a perfect fit for a desktop application.
If you need some advanced database solution similar to mysql, that is allowed to be distributed with commercial projects, then take a look at PostgreSQL, its license is non-restrictive (BSD/MIT alike).
Yes. PHP Desktop is released under the BSD 3-clause license that is almost non-restrictive. The only requirements are that the contents of the license.txt file is distributed along with your application in a plain readable form and that you mention in your product documentation that it uses the PHP Desktop framework.
Other third party libraries that PHP Desktop includes also use non-restrictive licenses that allow for commercial use:
- CEF and Chromium also use BSD 3-clause license.
- The Mongoose webserver is from revision 04fc209 that is MIT licensed (we don't use the latest Mongoose that went commercially and was GPL'ed).
- PHP uses the PHP License
- The JSON parser library uses the BSD 2-clause license.
In contrast to what name suggests, PHP Desktop Chrome really embeds Chromium browser (to be exact Chromium Embedded Framework which is based on Chromium browser), thus not all features of Google Chrome may be supported in PHP Desktop Chrome. Also note that currently PHP Desktop Chrome embeds Chrome 31 (branch 1650) and latest Google Chrome may be for example Chrome 38 (as of this writing).
To see if some feature/bug is working/fixed in newer CEF (Chromium Embedded Framework) release that PHP Desktop uses internally, please perform the following steps:
- Go to http://www.cefbuilds.com/
- Choose a branch
- Download Windows 32-bit >
TestApp
binaries - Run cefclient.exe and navigate to phpdesktop web server url (in phpdesktop from mouse context menu click "Open page in external browser")
Basic support for url rewrites is supported since PHP Desktop Chrome 31.8 / MSIE 1.14. This allows application to use pretty urls. See the 404_handler option in settings.json.
How do I call external programs or commands asynchronously in background without waiting for them to end?
A free command-line utility called "NirCmd" can come in handy. Download it from:
http://www.nirsoft.net/utils/nircmd.html
For example use the PHP exec/system commands along with nircmd tool:
exec('"C:/path/to/nircmd.exe" exec hide "C:/path/to/other/app.exe"');
NirCmd has the following useful commands among others:
exec command
Docs and examples: http://nircmd.nirsoft.net/exec.html
exec2 command
Docs and examples: http://nircmd.nirsoft.net/exec2.html
execcmd command
Docs and examples: http://nircmd.nirsoft.net/execmd.html
This issue was fixed in PHP Desktop 31.8.
Go to php/ directory and run script from command line. This will let you see for example if any of the php extensions failed loading. It may possibly also reveal other issues.
cd phpdesktop/php/
php.exe ../www/script.php
php-cgi.exe ../www/script.php
php.exe and php-cgi.exe are not exactly the same. These are two different programs and have a bit different implementations. It's best to test script using both executables, to increase your chance of detecting the issue. PHP Desktop uses CGI interface to execute php script and php-cgi.exe is for that. The other one php.exe is an official way for executing php scripts from command line. A php-cgi.exe uses special interface and isn't really suitable to be executed from command line, however it happens to work so it does not harm to test it as well.
Setting display_startup_errors=On
in php.ini will display php startup errors in a friendly manner using graphical message. This way you won't have to run script from command line to see the startup error, for example when loading php extension fails.
That error may occur when php startup fails. It may be a problem with php.ini configuration. Or may be that php script sent malformed or too big headers. Similar messages were reported in the past for Python binaries in Python Desktop, in that case a dll library was missing. You have to run script from command line to see the php startup error message. Alternatively you can set display_startup_errors=On
option in php.ini and you should see a graphical message about the real error (eg. loading extension failed). Problem reported in Issue #131.
This error may also occur when trying to load an incompatible php extension. PHP extensions are most often designed/compiled to work with a specific PHP version. You need to find out with what PHP version your dll extension is intended to work with. It's not only about PHP version number - but also whether this is x86 or x64, also there are TS and NTS variations of php. This all matters for your extension to load successfully. PHP shipped with phpdesktop is a x86 and a non-thread-safe version. PHP Desktop is not tied to any specific php version, you can replace PHP binaries by overwriting files in the php/ directory.
Error 500: Internal Server Error. Cannot spawn CGI process [C:\Documents and Settings...\www\index.php]: No such device or address
That error may occur when launching PHP CGI process fails. This will for example happen if you try to run phpdesktop with PHP 5.5/5.6 on Windows XP. If you would like to support Windows XP use PHP 5.4 instead, as this is the last series that supports this OS. Problem reported in Issue #127.
PHP doesn't support unicode paths, this may change in the next PHP 6 release, but until that it's a problem that can't be easily resolved. When PHP Desktop is launched from a location that contains unicode characters it will display an error message about the unicode problem.
One solution to the unicode problem would be to create an NTFS symbolink link pointing to the application directory and launch application using that symbolic link. However this will work only on NTFS partitions, it won't work on FAT/FAT32 partitions (application installer may detect that and act appropriately). If you don't have mklink.exe on your system you can download it from here. Example usage:
mklink /D C:\sites C:\gonzález\sites
You can read more about unicode issues and solutions in the Deployment issues section further down on this page.
If you get a black or white screen in PHP Desktop Chrome then this may be caused by incompatible GPU (video card) drivers. There are following solutions to this:
-
When PHP Desktop is updated to a newer Chrome version then the problem may be fixed.
-
Try updating your video card drivers to the latest version available.
-
You can disable GPU rendering completely so that only CPU will be used. Note that this will degrade performance if you're using any advanced 3D features in browser. It will affect 2d accelerated content as well. Disable GPU rendering by adding the "disable-gpu" and "disable-gpu-compositing" command line switches in the settings.json file, like this:
"command_line_switches": {
"disable-gpu": "",
"disable-gpu-compositing": ""
},
PHP Desktop does not put restrictions on what files a php script can access in OS. The default php.ini shipped does not have "open_basedir" option set that would limit file access.
PHP mail() function requires a local smtp server running on Windows. You can use PHPMailer library to send emails, it doesn't require a smtp server, see: https://github.com/PHPMailer/PHPMailer
Google Chrome bundles a proprietary version of Flash called Pepper Flash. PHP Desktop does not include Flash out of the box. You need to install Flash in your OS:
- Go to http://get.adobe.com/flashplayer/otherversions/
- Select an operating system
- Choose plugin: - If using phpdesktop v31 choose NPAPI version of plugin (for Firefox) - If using phpdesktop v47 or later choose PPAPI version if plugin (for Opera and Chromium)
- If using phpdesktop v47 or later, you additionally need to set the
--enable-system-flash
flag via command_line_switches option in the settings.json file:
command_line_switches: {
"enable-system-flash: ""
},
There are plans for encrypting and embedding static resource files (js/html/images) in the phpdesktop executable. See Issue #18 that is to implement this feature. Regarding PHP scripts, these can be protected using many of the available php encoders.
See this post from the PHP Desktop Forum: https://groups.google.com/d/msg/phpdesktop/G3hb0TeoPGA/AmYGUEj6ldAJ
With the steps from the post above you can make your application installer with PHP Desktop Chrome binaries to be only about 17 MB in size.
Use the php_com_dotnet.dll extension. It needs to be enabled in php.ini. To read from registry use this code:
$shell = new COM("WScript.Shell") or die("Requires Windows Scripting Host");
$some = $shell->RegRead("HKEY_LOCAL_MACHINE\\SOFTWARE\\...");
To write to a registry use the RegWrite method.
To import a .reg file issue a system command to execute the reg tool:
system("reg import file.reg");
Type "reg /?" from the command line to know more options for the reg tool.
See this post: https://groups.google.com/d/msg/phpdesktop/m2E3i7xD6i0/MvT7RjAUERcJ
A unique computer identifier is useful when implementing License Keys for your application to prevent unauthorized use.
You can get a Mac Address of a network adapter by parsing output of the "ipconfig /all" command with the system() function. Though there are many network adapters, some of them virtual and can be easily spoofed.
You can query registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography
for MachineGuid
which is generated during OS installation. But this can be easily spoofed using regedit.
You can query OS for some software/hardware information. For example to get Windows product unique identifier run the command:
C:\Windows\System32\wbem\wmic.exe path win32_computersystemproduct get uuid
UUID
E8F59000-0275-0000-0000-000000000000
Some notes:
- On some systems the wbem/ directory may not be in PATH, so to be sure we're providing the full path to the wmic executable.
- The "C:\Windows" path shouldn't be hardcoded, instead you should use
$_ENV["SYSTEMROOT"]
. - The MSDN page states that if uuid is not available, a UUID of all zeros is used.
- One of users has reported that UUID may not be unique on two different machines. See this post: https://groups.google.com/d/msg/phpdesktop/YbuXL_FVZRQ/0YSc0uZwAjsJ . It's best to query multiple software/hardware information and create unique hash based on these values.
To query processor identifier (in this case there isn't available a unique identifier, only identifier of the processor model which may not be unique):
C:\Windows\System32\wbem\wmic.exe path win32_processor get uniqueid
UniqueId
C:\Windows\System32\wbem\wmic.exe path win32_computersystemproduct get uuid path win32_processor get processorid
ProcessorId
BFEBFBFF000306A9
You can query many other hardware information:
win32_computersystemproduct: name, uuid, vendor, version
win32_processor: uniqueid, processorid, name, manufacturer, maxclockspeed
win32_bios: manufacturer, smbiosbiosversion, identificationcode, serialnumber, releasedate, version
win32_diskdrive: model, manufacturer, signature, totalheads
win32_baseboard: model, manufacturer, name, serialnumber
win32_videocontroller: driverversion, name
You have to decide which ones will decide about uniqueness of a computer. You may want to query several of them and not depend only on one, as sometimes it may not be available, or be of zeroes like uuid. After you obtain a few of such strings you can calculate a md5 hash to have a short unique identifier.
See this MSDN page for more win32 classes that you can query: http://msdn.microsoft.com/en-us/library/aa394084(v=vs.85).aspx
PHP example code for fetching output of a command:
$output = shell_exec("echo | {$_ENV['SYSTEMROOT']}\System32\wbem\wmic.exe path win32_computersystemproduct get uuid");
if ($output) echo "Command succeeded. Output=".$output;
else echo "Command failed.";
The "echo | command.." syntax is to avoid hang that happens for some programs on Windows XP, see Issue #124 for more details.
To be able to use getUserMedia() function you need to set the "enable-media-stream" switch in the settings.json file.
See also this post on the forum: https://groups.google.com/d/msg/phpdesktop/RJEnq_CfLIg/YdrXitCRndUJ
The storage doesn't persist between application restarts. The issue is that the storage is binded to both domain and port. PHP Desktop by default listens on a random port assigned by OS, to avoid port conflicts. The solution for the storage to persist is to set a fixed port (eg. 54007) in the settings.json file:
"web_server": {
"listen_on": ["127.0.0.1", 54007],
See Issue #108 that is to alter Chromium behavior to allow for random port, while still being able to use persistent storage.
Currently requests for more persistent storage space don't work, see Issue #107.
First, some things to clarify. What PHP Desktop really embeds is a Chromium browser that Google Chrome is based on. Though, Chromium is open source, Google Chrome is not. There are proprietary audio/video codecs that are not free like MP3 / AAC / MP4 / H.264. Google Chrome is a commercial project and they bought licenses so that they can distribute proprietary video/audio codecs.
Open the html5test.com website in the PHP Desktop browser and see the results for audio/video support (as of PHP Desktop Chrome 31.3):
Audio support
audio element Yes ✔
Web Audio API Prefixed ✔
Speech Recognition Prefixed ✔
Speech Synthesis No ✘
PCM audio support Yes ✔
AAC support No ✘
MP3 support No ✘
Ogg Vorbis support Yes ✔
Ogg Opus support No ✘
WebM support Yes ✔
Video support
video element Yes ✔
DRM support Prefixed ✔
Media Source extensions Yes ✔
Subtitle support Yes ✔
Poster image support Yes ✔
Codec detection Yes ✔
MPEG-4 support No ✘
H.264 support No ✘
Ogg Theora support Yes ✔
WebM with VP8 support Yes ✔
WebM with VP9 support Yes ✔
You can check for user agent string which will be usually very specific. For example in PHP Desktop Chrome it is "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36
". You should be safe to check against it, as users will usually have the latest Google Chrome installed on their system.
You may also overwrite that user agent string with your own by setting the "user-agent" switch through the command_line_switches option, see the Chrome settings wiki page.
You may also check through javascript for the "phpdesktop" object. This object will be available only in phpdesktop embedded browser, see the Javascript API wiki page.
See this post on the forum: https://groups.google.com/d/msg/phpdesktop/xN-fNB0C4Yg/LZ80-fP0tYIJ
UPDATE: Information about deployment further down in this section is not accurate in regards to write permission in the Program Files directory. Windows Vista/7 and later have a backward-compatibility feature that when a program installed to C:\Program Files (x86)\xxx
tries to write some files in that directory (which requires administrative privilages), OS will redirect these file operations to the C:\ProgramData\xxx
directory. This way old applications from the WinXP days can still function by writing files in app's directory. However if you try to modify existing app files (eg settings.json) then this won't be possible without administrative privilages for application. See also this question on stackoverflow.
Due to UAC security features on Windows Vista/7/8 you don't have permission to modify files in the "Program Files" or "Program Files (x86)" directories, it requires administrative privileges. So if you install the application to the Program Files directory, your scripts residing in the www/ directory, won't be able to write files inside that directory. You are supposed to save your data (database, file uploads) in the "c:\Users\%user%\AppData\Local\appname"
directory (use the $_ENV["LOCALAPPDATA"]
env variable).
If you have scripts that already write in the www/ directory and do not want to modify them, then you should configure the application installer to install the whole www/ directory to the "c:\Users\%user%\AppData\Local\appname"
directory and the rest of the files (dlls, pak, exe, php/ dir, locales/ dir) to the Program Files directory. If you do so, your installer needs to modify the "settings.json" file that is residing next to the phpdesktop executable, and change the "www_directory" setting (in "web_server" section) to point to the "c:\Users\%user%\AppData\Local\appname\www"
directory. The "log_file" option should also be in a writable path.
Another solution that is most straightforward, is to just install the whole application to the "c:\Users\%user%\AppData\Local\appname"
directory.
But there is a problem with the solutions above. PHP does not support unicode paths on Windows. The path to the php/ directory and path to the www/ directory cannot contain unicode characters. But user's name may contain unicode characters. Thus your app would be in "C:\Users\Ąąśóć\AppData\Local\"
directory and this would cause php interpreter errors due to unicode characters in the path.
The unicode path issues are not a concern when using the sqlite file database. See the explanation further down.
There is the "C:\Users\Public" directory that is writable for any program. You could install app to that directory. But this is still not perfect, as you're providing a single instance of application for all users.
You may install the whole app to the Program Files directory and still have permission to write in that directory by embedding a manifest in the phpdesktop executable that requires administrative privileges to run. This way all your files including the www/ directory may reside in the Program Files directory, and there won't be problems modifying files in that directory. One drawback is that your users may hesitate giving your application administrative privileges. This solution is not good from a security standpoint. See an example manifest that you would have to embed: RequireAdministrator.manifest.
To sum up, you can try the following approaches to the write permission and unicode paths problems:
- Install the whole app to the "C:\Users\Public\appname" directory. This allows only for a single app installation for all users. Your application installer should handle Windows XP case, as C:\Users\Public doesn't exist on that OS.
- You could add condition in your app installer, so that it detects if user's name contains unicode characters. If it contains then install app to the "C:\Users\Public\appname" or "Program Files" directory. This allows only for one app installation for all users. If user's name does not contain unicode characters then install application to the
"C:\Users\%user%\AppData\Local\appname"
directory. - Install the whole app to the "Program Files" directory. This allows only for a single app installation. You also must embed the RequireAdministrator.manifest in the phpdesktop executable so that app has write permission in the directory it has been installed to.
- You could ignore the whole unicode paths problem if your users language is English. It might work for you in 99% cases.
It seems that the sqlite database handles the utf-8 paths just fine (tested with pdo sqlite). This extension seems to work independently, thus the php unicode path problems are not an issue when using sqlite. If your application only needs to keep the sqlite database in user profile directory then you should be fine.
There are some ways to access the unicode paths using external libraries/extensions:
- See the php-wfio extension for PHP 5.4 only. Using a special scheme "wfio://" you can access unicode paths. See the examples in the tests directory. The extension needs to be build from sources.
- See the WinFsStreamWrapper.php class. It requires the "php_com_dotnet.dll" extension and uses the COM object to instantiate Windows Scripting object. It suffers from Windows sometimes returning non-ASCII chars in shortPath on non-latin computers. No workaround found currently. Thus the php-wfio extension is a more reliable solution.
PHP 6 is planned to support unicode filenames on Windows. A quote by Pierre Joye from 2013-01-07:
A better solution I work on for previous php version (incl. 5.5 as I
won't make it in time) is an extension which would override existing
functions. Next major version (6) will support unicode filenames,
which will solve the 255 chars horrible limitation.
Reference: http://marc.info/?l=php-internals&m=135758611811889&w=2
By default the MSIE control embedded caches the pages and the css/js files. There is no option to disable that cache, you have to handle this yourself by sending appropriate no-cache headers for the php pages and by adding some random variables to the path of the css/js files to prevent the caching:
<link href="style.css?r=<?php echo time(); ?>" rel="stylesheet" type="text/css">
PHPBrowserBox - This is a standalone windows browser that runs an internal php/mysql and allows you to package your web apps like a windows desktop app. It supports Apache 2.4.20 / php 7.0.8 / mysql 5.7.13 / HTML5 / NODE.JS commands via its node webkit interface.
ExeOutput (commercial) - supports IE and Chrome. This project wasn't updated since a year and the latest version available embeds and old version of Chrome (21.x). It embeds PHP using PHP API. PHP scripts are embedded in exe and may optionally be encoded using bcompiler (up to PHP 5.3 only). It does not serve webpages through CGI/webserver like PHP Desktop does, so memory leaks may be an issue. Embedding PHP interpreter through PHP API has disadvantages, some features work differently. There may be issues with uploads, output buffering, includes, paths and others. There are issues with running more than one php script simultaneously. Some php extensions may not work.
TideSDK (beta) - embeds the Webkit engine. No webserver is running, embedding is done using PHP API. PHP is embedded on a webpage similarly to a javascript language, so it can interact with DOM. The downside of that is that it requires you to program in a certain way. Most probably you won't be able to reuse existing scripts. Frameworks like Laravel or Zend Framework won't work. This project was abandoned, the authors are working on a successor called "TideKit".
ZZEE PHPExe and ZZEE PHP GUI - both embed Internet Explorer engine.
Titanium Desktop for PHP - embeds the Webkit engine. This project is similar to TideSDK, though it it is not developed anymore since about 2-3 years.
Wapache - embeds Apache 2 webserver and uses Internet Explorer engine.
PhpDock - not developed anymore, last release was 3 years ago. Uses Internet Explorer engine.
Nightrain - supported on many platforms (Win, Mac, Linux), but doesn't seem to provide a stable infrastructure. It embeds a different browser on different platforms (IE on Win, Webkit on Mac/Linux). Uses a php built-in single threaded web server that is not intended for production. There are many other issues like for example you can't hide debug console when running app on Windows.
See a list of PHP to EXE compilers/converters in this stackoverflow question: "Convert a PHP script into a stand-alone windows executable".
Node-webkit - does not support PHP, but still worth mentioning. You can write native apps in HTML and Javascript with node-webkit. It also lets you call Node.js modules directly from the DOM.
PHP-Webkit - The goal of php-webkit is to be able to package a PHP app within a NW.js project without needing the user to install and set up PHP on their system or connect to a remote PHP codebase.
PHP-GTK - a set of language bindings for PHP which allow GTK+ GUI applications to be written in PHP. PHP-GTK provides an object-oriented interface to GTK+ classes and functions.
wxPHP - a PHP extension that wraps the wxWidgets library, which allows to write multi-platform desktop applications that make use of the native graphical components available to the different platforms.
WinBinder - low-level Windows API bindings for PHP.
PHP-Qt - an extension for PHP5 that aims to write software with the Qt toolkit (a cross-platform application framework).