[CubicleSoft Presents...]
[PHP App Server Overview and Tutorial]
Hello.
In this video, I'm going to show how to get started with CubicleSoft PHP App Server to
create lightweight, installable applications written in HTML,
CSS, Javascript, and PHP for the Windows, Mac, and Linux desktop operating systems.
At the end of this video, I will have started creating a real software application and made
fully functional installers for Windows, Mac, and Linux.
Feel free to follow along.
The first step is to obtain a copy of PHP App Server.
I've already downloaded and extracted the latest version of the software.
When using git clone, be sure to create a fork and a separate branch for your app before
beginning development.
Doing so avoids accidentally overwriting your changes whenever you fetch upstream updates
for PHP App Server.
Let's start by looking at the project's directory structure.
First up is the 'www' directory.
This is where standard web server files go for the application.
Next is the 'support' directory.
This directory contains all of the files needed by 'server.php'.
'server.php' is the core of the product, which I will be running shortly.
Next is the server 'extensions' directory.
This is where long running processes, high performance APIs, and WebSocket interfaces
can be created.
And, finally, the secret sauce that brings everything together: The 'installers' directory.
This is where we'll eventually wind up to prepare the various application installers.
PHP App Server is actually a fully-featured and extensible web server written in PHP with
WebSocket support, virtual directory support, dual document roots, access and error logging,
and much more without having to mess around with any configuration files.
Creating a quick information dump script called 'index.php' and copying it to 'api.php in
the 'www' directory allows for experimenting with the server right away.
Since I already have PHP installed on my development machine, I'll see what options are available
by running 'php server.php -?'
There are quite a few options but, for quick development purposes, I can set what port
to start the server on from the command-line by running 'php server.php -port=9002'.
PHP App Server is now running a localhost only web server on port 9002.
Here, we can see the output at various URLs that confirm that the web server works out
of the box and is indeed processing PHP.
If you are following along on your own computer, feel free to pause the video and try various
URLs to see what sorts of things are possible.
I'm going to use CubicleSoft Admin Pack as the basis of the application and place it
into 'www'.
You can, of course, use whatever software or framework you prefer.
Next, I'm going to quickly create a little application that displays a few values specific
to PHP App Server and the associated directory structures.
Okay, the app is ready.
Let's start building the final package, which I'll uncreatively call 'Basic Info 1.0'.
To avoid the risk of upgrades to PHP App Server overwriting my files, I'll rename files that
start with 'yourapp' to 'basic-info'.
For a real software product, I would also make my own app icon but the icon that is
included is good enough as a placeholder.
Now it is time to build real installers!
PHP App Server comes with two pre-made boilerplate installer scripts for Windows, one for Mac,
and one for Linux.
There are 'README.md' files in each installer directory that cover the required steps to
successfully create each installation package.
When building installers for Windows, start in the 'win-innosetup' directory.
Setting up the first build for Windows is the most involved process out of all of the
packagers.
This process also produces the largest installers due to needing to specially package and distribute
PHP for the platform.
First, load up the 'php-win-32' and/or 'php-win-64' directories with the version of PHP for Windows
binaries that are known to work with the application.
An application only needs to include the extension DLLs that it actually uses.
Create and adjust 'php.ini' as necessary.
[Elevator music playing...]
Once everything looks good, run the 'prepare-php' batch file on a Windows box or a Windows virtual
machine to prepare the binaries for release.
Inno Setup is required to build the actual installer package.
So be sure to install the latest release of Inno Setup.
Next, rename and then double-click the ISS file to launch the Inno Setup compiler script
editor.
Make changes to the various defines at the top of the file, save it, and then run the
compiler.
Finally, test the generated installer package and run the newly installed application.
The first installer is done.
Let's move onto the second installer packager located in the 'win-wix' directory.
Install the latest release of the WiX Toolset from wixtoolset.org.
Next, rename the WXS file and edit the file using a text editor.
Again, adjust the various defines at the top of the file.
Run 'uuidgen -C' to generate a GUID for the UpgradeGUID define.
Once done, save the file.
Finally, run 'build.bat' or 'build_64.bat' depending on whether or not the Inno Setup-based
installer we just created only runs as a 64-bit installer.
A deployable MSI file is output.
Finally, verify that the generated installer package works.
The second installer is done.
Let's move onto the third installer packager located in the 'nix-tar-gz' directory.
Edit the 'php-nix-install.sh' file located in the 'install-support' directory and add
any necessary PHP extensions to the list.
I recommend using virtual machines with various Linux distros set up to figure out what packages
need to be installed for the application to work.
In the main 'nix-tar-gz' directory, rename and then edit the JSON file.
Once again, adjust the various values.
To prepare the installer, I'll transfer my application to an Ubuntu Linux virtual machine...
And run 'php package.php' from there.
A tar-gzipped file is output.
Test the installer package by extracting the tar-gzipped file somewhere.
Then run './install.sh' or 'sudo ./install.sh' to install the application.
And finally run the newly installed application.
The third installer is done.
Let's move onto the last installer packager located in the 'osx-tar-gz' directory.
Rename and edit the JSON file.
Again, adjust the various values and save the file.
Run 'php package.php'.
And another tar-gzipped file is output specifically for OSX.
Test the generated installer package on Mac OSX and run the application.
This concludes this intro video on building installable applications with PHP App Server.
I'm looking forward to seeing what applications everyone builds with this nifty software solution.
Be sure to like and subscribe.
And Thank You For Watching!
Không có nhận xét nào:
Đăng nhận xét