11

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

5
  • 1
    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. Commented Jan 8, 2015 at 18:12
  • what do you mean 'offline'? without Internet access? Just install all on localhost server for example XAMP - and you don't have to be plugged in :) Commented Jan 8, 2015 at 18:12
  • I think you need to clarify your question, David. Do you mean you want to develop a Laravel app locally, or do you want your app to work offline for users on their devices? Commented Jan 8, 2015 at 18:20
  • A valid question @David (+1) how did you implement the solution. What is actual feedback of client after using it in production...? I have to build such system and need to know if solution work in real life... Commented Oct 6, 2015 at 7:53
  • 1
    Hey @hhsadiq, we decided to use Meteor - which is awesome! using the Appcache Package (which stores the assets in the appcache) and the ground:db Package (which stores the db in local storage) we were able to use our app offline. We are currently using it to build an iOS and Android app using the Cordova Phonegap integration. Commented Oct 6, 2015 at 15:14

1 Answer 1

8

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.

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks @Lorez Meyer! Will look into this! Thanks for giving me a solution rather than just telling me "you cant" and marking me down... much appreciated! :)
@LorenzMeyer i know this is an old question, but what about if u r using ajax with laravel, so on each request to the server u make "in case of updating or adding new record" we will check if the connection is down and if it is we will then use the html5 localStorage and notify the user that this data will be posted to the server once the connection is back, couldnt this be done ?
@ctf0 I think what you propose can work. Even though I fear that the implementation will be heavy.
@LorenzMeyer can u elaporate more plz, for the offline checking i was going to use something like krawczyk.io/heyoffline.js
Really, I can't give advice on this. My answer already reflects what I can say to this question. I do not know much about Laravel. By the way, I think that the backend is not relevant.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.