Userstory: CakePHP and phpdesktop; works like a charm!

402 views
Skip to first unread message

Stefan van Gastel

unread,
Feb 24, 2014, 2:37:16 AM2/24/14
to phpde...@googlegroups.com
Hi,

I recently was looking for a way to 'ship' my PHP application to a customer for demonstrator / prototype review purposes. I first started looking for php to exe kind of packagers. There are some commercial tools that can do that but the one I really liked at first sight was phpdesktop! I also found Nightrain (http://www.nightrain.naetech.com/) which does almost the exact same but has a huge downside (in my opinion) and that is the Qt dependency. This requires my user to download and install 500+ Mb of Qt for Windows in order to run the application. The upside of Nightrain is the cross-platform support.

Back to the problem I needed solving; Shipping my entire application in a zip file containing a simple exe to start running my app. Phpdesktop obviously was the way to go and I started out by downloading it and placing my PHP code in the ww directory. The framework I use for my applications is CakePHP (http://cakephp.org) and this required some extra steps to get it working. Before I get into detail about the exact steps taken I want to skip ahead to my final solution. In my early CakePHP years I once heard someone say; Pluginize all things, and that is exactly what I did. I embeded phpdesktop into a CakePHP plugin making it possible to install that plugin (called Cakedesktop) and create an offline phpdesktop-based CakePHP application directly from your webbrowser.

In short, any CakePHP user can download their webapplication to a desktop application. The steps the plugin currently takes are the following:

0. Retrieve options from initial webpage (users can specify things like fullscreen, application name, etc.)

1. Copy phpdesktop skeleton dir to tmp dir
2. Copy entire CakePHP directory to tmp dir's www dir
3. Apply options for phpdesktop (as given in step 0)
4. Copy loaded php extensions to new php.ini (check loaded extensions and copy them tot be loaded in phpdesktops php.ini, to get max compatibility)
5. Remove .htaccess files (Mongoose has no mod_rewrite for pretty urls)
6. Edit core.php and bootstrap.php to disable url rewrite and remove this plugin
7. Dump MySQL database (pure php code, no mysqldump command)
8. Convert SQL to Sqlite compatible SQL (work in progress)
9. Edit database.php to activate Sqlite
10. Import database structure and data in Sqlite
11. Zip package
12. Cleanup job dir
13. Serve package

So that's it folks, a complete PHP application as a standalone Windows desktop application in less than a minute depending on the speed of your webserver ;)

The project has been submitted and accepted to the CakePHP plugin repo (http://plugins.cakephp.org).

GitHub url: https://github.com/stefanvangastel/CakePHP-Cakedesktop

And ofcourse my thanks to Czarek Tomczak! Keep up the good work!

Czarek Tomczak

unread,
Feb 24, 2014, 4:30:05 AM2/24/14
to phpde...@googlegroups.com
Hi Stefan,

Thanks for sharing this with us.
And nice work.

Best regards,
Czarek

Terry

unread,
Feb 24, 2014, 8:13:06 AM2/24/14
to phpde...@googlegroups.com
That is awesome Stefan!

Thank you for sharing, have been wanting to dig into cakePHP for some time and now no excuses left.

Terry

kob...@gmail.com

unread,
Oct 10, 2014, 3:16:07 PM10/10/14
to phpde...@googlegroups.com
Thaaaaaaaaaanks

okiaso...@gmail.com

unread,
Jun 21, 2015, 2:04:25 PM6/21/15
to phpde...@googlegroups.com
A very big thanks sir.
Reply all
Reply to author
Forward
0 new messages