2

I've a sort of task manager app which the backend is written in PHP and the front-end in vuejs+HTML+CSS, so my understanding is that it is fairly easy to bundle the front-end part into a hybrid app by something like Electron, but I also want to get rid of the server-side interactions and allow all the database storage to take part on user's computer.

I can imagine a tech-savvy user be able to easily setup Laravel+MySQL & run the server on his or her desktop, but of course, my ultimate vision is to have the whole setup process and data handling be invisible to the user.

I've seen task managers that store tasks into files and then read and write from via Electron and JS, but I think, I rather stick with using a Database and beside the Database, Models and Controllers, I think I can skip all extra futures that having that app run on a server would provide.

Any suggestion how to best make this happen? Preferably without adding an extra language to JS+PHP. Or if this isn't possible, what is the other alternatives to keep the VueJS+HTML+CSS front-end as it is but translate the PHP code to some other language that can be compiled for cross platform, or at least Linux + MacOS?

2 Answers2

1

I would suggest removing the PHP. If you’re up for some coding work, you should port every PHP function into JavaScript and use LocalStorage or some Node-friendly ORM like Waterline for your storage needs. Electron is basically a browser with a server strapped to the back. If all you need the server to do is store data, use Node. Anything else will cause more work for you and more risk of things breaking in the future as the technologies migrate away from each other.

Holland Wilson
  • 701
  • 4
  • 16
  • This answer and the question were both cross-posted between here and the Atom/Electron forums. Stack Overflow is not intended for lengthy discussion of solutions or code review, so hashing out the technical specifics should probably happen on the forum. Here's a link to the thread: https://discuss.atom.io/t/architecture-how-to-move-php-laravel-vuejs-app-to-hybrid-app/54237 – Holland Wilson Apr 12 '18 at 22:56
  • thanks for remarks about how to use stack overflow, I'm not really familiar which channels to use for which purposes & I kind wish to have different perspective on the matter ... – Captain Husayn Penguin Apr 13 '18 at 22:25
  • 1
    The community here is invested in a formal style of questions and answers recorded for posterity with maximal reference value for future readers. Technical details have a place, but it is preferred for the planning discussions of the development of a piece of code happen through other channels. If there are code snippets that directly answer the question, the answer can be edited to include a more complete solution. – Holland Wilson Apr 13 '18 at 22:29
0

So I am just going through this myself, and I have to say it'll depend on how much of laravel you are using to display your website currently. For me, I was already using Vue, Vuex, Vue Router, so I just grabbed electron-vue and just started bringing over all my Vue components, js files, and SCSS files. Had to change a few import directories here and there, install a SCSS compiler for webpack, and remove the remains few Blade functions I had, but afterwards I had the exact same front end as my website. Grabbing content was as easy as connecting to various API endpoints for data, using passport to setup OAuth2 for user logins, and caching a few details just in the local storage. So far I haven't needed anything beyond that, but with electron you have (more or less) full access to the OS like a regular application. Interacting between the front end site and back end api / back end electron instance has been the trickier part, but I'm just going through simple tutorials and building up the features I want one by one.

My Advice would be to start by simply moving your Vue front end over into vue-electron. Then once you have that setup, start making API calls to your endpoints. I'd recommend watching some https://laracasts.com videos on using laravel as an API and such (not affiliated, just very happy with the quality of Jeffrey's work). Once you start playing around with using laravel as an API backend, I think you'll find things just start to fall in place and make sense.

Xander Luciano
  • 3,753
  • 7
  • 32
  • 53