Bundling PHP Application, XAMPPLite 1.7.3 Using Winrar

No Comments
Begin from a task given by my boss to create a standalone application using PHP running on windows operating system. Got confused thinking about how to bundling web server + PHP + MySQL into an .exe file (Windows Executable File). Finally, I can do this, helped by my coworker and I will share to you all.

First thing first, you need to collect the tools:
  1. PHP Application that you want to bundle
  2. Portable Web Server, I use xampplite 1.7.3 as my web server because my PHP Application using PHP 5.3. There are other portable web server that you can use, server2go but I will tell it how to do with it later.
  3. Winrar.
If you have collected all, then do the following step:
  1. Backup your database application.
  2. Extract xampplite 1.7.3 to C:\. Why I choose C root directory, because this is normally installation folder location for windows operating system and this folder absolutely exist.
  3. Copy your PHP Application to htdocs in xampplite 1.7.3 extracted folder.
  4. Make sure that no one web server / mysql server running, then you can run apache and mysql by double clicking apache_start.bat and mysql_start.bat or you can run xampplite control panel to start apache and mysql. 
  5. Access your phpmyadmin by type localhost/phpmyadmin using your favourite browser.
  6. Create new database and then restore your backed up database via phpmyadmin. 
          If you got this following error, when try to access phpmyadmin,
    error #1273 unknown collation utf8mb4_general_ci 
    Open database_interface.lib.php located in C:\xampplite\phpMyAdmin\libraries, then comment at this line:
    error #1273 unknown collation utf8mb4_general_ci

    Then run your phpmyadmin again. If you have restored the database, setting your application then try to running your application via browser by type: localhost/myapplication. If everything's gonna be okay, then we can start to the next step.
    Before bundle this application, we need to create batch file that will be executed after installation process was done. Create new file, filename.bat then open it with your favourite text editor, and add this codes,
call apache_start.bat 
call mysql_start.bat
if exist {"C:\Program Files\Mozilla Firefox\firefox.exe"} {
    "C:\Program Files\Mozilla Firefox\firefox.exe" localhost/myapplication
}
    Above code is used to run apache_start.bat, mysql_start.bat and run your web application using firefox (x86-windows 32 bit).

    Now we have to create an .exe file to run your web application. You just need Winrar to do that. Select all folder under xampplite, right click then choose add to archive,
     Fill archive name with application name, check create SFX archive and create soli, then move to Advanced tab, shown below,
    I suggest to fill this path to extract, same as the extracted xampplite folder (C:\xampplite\), and don't change it, because if you change it, you could change many files under xampplite folder with your custom folder. Run after extraction is used to execute batch file (that has created before) after extraction was completed. You can try to custom in this advanced SFX options, like installer title, installer icon, license and many more. If you have done to custom your installer, then just click OK and wait the process, and when it done, just try to install it to other computer (make sure there is not web server running).

    Conclusion
    This method usefull enough to create web application into an .exe file. This is actually not create an application (like desktop application) but just compress portable web server that include your application and databases and then it could be portable.


    If you have a question don't hestitate to comment below.
Next PostNewer Post Previous PostOlder Post Home

0 comments

Post a Comment