-
Notifications
You must be signed in to change notification settings - Fork 6
Knowledge Base
Table of Contents
- Hello World HTML!
- Hello World PHP!
- How does PHP Desktop work?
- Should I use PHP 7.3 or newer?
- PHP Support Packs
- Useful tools
- How do I protect PHP sources in the "htdocs" directory?
- Settings
- Application name
- Application details
- Application installer
- How to use MySQL?
- Can I use PHPBrowserBox in a commercial closed sourced project?
- Url rewriting support
- Problem running PHP script
- How Do I Refresh Page
- Troubleshooting
- Download the phpbrowserbox app and extract it
- Run the "phpbrowserbox.exe" executable
- What you see in application window is the output generated by HTML file in the app/startup/index.html directory. PHPBrowserBox runs HTML by default.
- To ensure that you only run HTML, check app/application.json and ensure that you have the setting
"main": "/startup/index.html",
"config": {
"startup": true,
"apache": false,
"mysql": false
}
- To change the location of the startup page, you can alter the main configuration
1. Download the [phpbrowserbox app](https://github.com/dhtml/phpbrowserbox) and extract it
2. Download [php 7.3 support zip](https://github.com/dhtml/phpbrowserbox) and extract it. Ensure that you maintain the structure **app/bin/apache**
3. Run the "phpbrowserbox.exe" executable
4. The startup page first loads, followed by the hello world php script. The hello world php script output is generated by app/htdocs directory.
4. To ensure that you run the startup page followed by php, check app/application.json and ensure that you have the setting
```
"main": "/startup/index.html",
"baseUrl": "/",
"config": {
"startup": true,
"apache": true,
"mysql": true
}
```
5. To change the location loaded e.g. if you were to have a wordpress setup in your htdocs and you wish to start with say /wp-admin, then change the baseUrl to "/wp-admin", if you wish to load say info.php then the baseUrl should be "/info.php"
6. To disable the HTML startup page, simple set startup: false inside the config shown above.
7. When you're done playing with the default scripts clear the htdocs/ directory and copy your own PHP scripts. If you're using a PHP framework then see the [PHP frameworks support](PHP-frameworks-support) wiki page that provides step by step instructions for configuring many popular frameworks.
First, an Electron App is started. This will start the desktop app, and will optionally load a startup html page (if it is enabled). Next, it will start MySQL in the background if enabled from the config. The next is line is Apache Server if this is enabled. Finally, baseUrl is loaded to replace the startup page once the apache server is fully loaded and initialised.
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 phpbrowserbox binaries with no external dependencies.
Technically speaking, PHPBrowserBox supports almost all versions of PHP from 5.3 and above. But let us focus on php 7.3 and above as most modern applications fall in this category. There are support packages created already for php 7.3+, you need to identify the php version required by the application you are using and ensure that you download and setup the appropriate support pack into your setup.
Learn more about the support packages here. These support packages are what makes PHPBrowserBox support different versions of PHP, MySQL and Apache.
- NSSM, the Non-Sucking Service Manager - https://nssm.cc/
- Inno Setup, create app installer for Windows - https://en.wikipedia.org/wiki/Inno_Setup
- PHPMailer, send emails without smtp server - https://github.com/PHPMailer/PHPMailer
- ResourceHacker, edit icon embedded in exe - http://www.angusj.com/resourcehacker/
You can load custom php extensions, thus you can use many of the available php encoders such as:
- 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.
- Commercial
- Ion Cube
- Zend Guard
- Source Guardian
- Nu-Coder
- CodeLock - a cheap one
The main settings are inside application.json. To learn more click here
Rename the "phpbrowserbox.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 "PHPBrowserBox", 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 "phpbrowserbox.exe" (or whatever the name of your executable is).
- On the left side a tree control will appear. Expand "/Version Info/1/1022" and change the strings: "FileDescription", "FileVersion" and others.
- Save it.
PHPBrowserBox 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.
If you are using any of the PHP Support Packs and you have mysql enabled in the configuration. You will have MySQL enabled.
The configuration will be:
User 1 : username: root password: No password
User 2: UserName: admin Password: password Port: The port will depend on your setting of application.json but default setting is port 81. To configure this in wordpress for example, your host config will be localhost:81
While the application is running, it is possible for you to even connect to MySQL Console by doing this:
- point your console to whatever directory phpbrowserbox is running, then
C:\> cd app/bin/mysql/bin
C:\> mysql -u root
that should take you right in.
Note for commercial use: 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:
- PHP uses the PHP License
PHPBrowserBox supports url rewriting via mod_rewrite apache module. All the php support packages support this by default.
- You can refresh any page by pressing "CTRL+R" together using your keyboard.
- You can also setting the "autoHideMenuBar" to false from Settings to enable the menubar.
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 phpbrowserbox/app/bin/php/bin
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. PHPBrowserBox uses DLL interface to execute php script.
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.
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
PHP Desktop - PHP Desktop is an open source project founded by Czarek Tomczak in 2012 to provide a way for developing native desktop GUI applications using web technologies such as PHP, HTML5, JavaScript and SQLite.
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).