Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel: Offline Mode?

I want to make my web app (which is built with laravel) work offline...but I cant found out how to do it!

I am using the "app cache" for static files, but im not sure exactly how to handle the dynamic side of the app.

The app uses a database which im guessing I need to use localStorage for? (from what ive read online so far)

Im basically just looking for someone to point me in the right direction as im struggling to find much online on setting up Laravel for use offline

Thanks, Dave

like image 785
David Avatar asked Jan 08 '15 18:01

David


People also ask

Can you use laravel offline?

You can't. Laravel's written in PHP, which is a server-side language. No server, no app. If you want your app to work offline, you need to look into a client-side language, like JavaScript.


1 Answers

You can only have a static site offline with appcache. You cannot do this with laravel.

If you want to move the data into localstorage and have a semi- dynamic website, you have to completly change your architecture. Let me outline a possible approach :

A single page web app written in javascript ( using a framework like for instance ExtJs ) that connects to a backend in a form of a webservice that gives access to the database ( you could write it using laravel ).

When you are connected to the server you can load the data in localstorage When you are offline you can continue to work with the data. When the client reconnects, you have to synchronize the changes with the server.

Edit: As of 2020, Application Storage is deprecated. Look into ServiceWorkers instead.

like image 55
Lorenz Meyer Avatar answered Oct 11 '22 23:10

Lorenz Meyer