how to build a php mysql application that works offline

时光毁灭记忆、已成空白 提交于 2019-12-02 21:02:05

There are essentially 3 ways to go:

Version 1: "Old school": PHP-Gtk+ and bcompiler

  • first, if you not have done so already, you need to separate your business logic from your presentation layer (HTML, templating engines, ...) and database layer
  • then adapt your database layer, so that it can live with an alternative DB (local SQlite comes to mind) and perform synchronisation when online again
  • Finally use PHP-Gtk+ to create a new UI and pack all this with bcompiler

Version 2: "Standard": Take your server with you

  • Look at Server2Go, WampOnCD and friends to create a "double clickable webserver" (Start at Z-WAMP)
  • You still need to adapt your DB layer as in Version 1

Version 3: "Web 2.x": Move application from server to browser

  • Move your application logic from the server side (PHP) to the client side (JS)
  • Make your server part (PHP) only a data access or sync layer
  • Use the HTML5 offline features to replace your data access with local data if you are offline and to resync if online

Which one is best?

This depends on what you have and what you want. If most of your business logic is in PHP, then moving it into the browser might be prohibitingly expensive - be aware, that this also generates a whole new class of security nightmaares. I personally do not recommend porting this way, but I do recommend it for new apps, if the backing DB is not too big.

If you chose to keep your PHP business logic, then the desicion between 1 and 2 is often a quiestion of how much UI does your app have - if it's only a few CRUD forms, 1. might be a good idea - it is definitly the most portable (in the sense of taking it with you). If not, go with 2.

Have a look at HTML5's application cache. That's pretty much what it's for. There are plenty of tutorials around for this, so have a look around and see if it suits your needs.

I have worked with similar system for ships. Internet is expensive in the middle of the ocean so they have local web servers installed with database synchronization via e-mail.

We also have created simple .exe packages so people with no experience can install the system or update system...

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!