FireBase and Php (Laravel) - angularjs

I have a Laravel + mySQL app that use either ajax or Angular $http service and I want to integrate websockets into that mix.
So I thought of trying Firebase, which is great and easy to use, but am a bit confused about a couple of things. I am seeking for someone's help in clearing that confusion.
is it possible to change the app url name for firebase ?
So instead of something like https://vivid-torch-xxx.firebaseio.com can I change it to https://myawesomesite.firebaseio.com?
how the schema on Firebase should be structured ?
Or better yet how not to use it all and just use Firebase as websocket server instead of ajax ?
I essentially don't want to have 2 databases to manage the data.
there is a Firebase package for php/laravel, but I don't know why would I need it. Or what exactly is the benefit of using it if am already using a REST-ful backend with angular.

The schema will basically be how you want your JSON for your front-end will read it. Are you displaying notifications? Then investigate how that would be structured. Firebase will give you the power to push updates to the front-end which then will no longer have to pull data via the API on what the actual data is it needs to display the notification.

Related

How to understand data storage for a React app?

I am learning web dev and I am planning on developing a simple web app using React: a decision matrix tool. 
I need users to be able log in and save their matrices under their profile so I prefer to not use LocalStorage and thus learn more about databases. I am thinking of using JSON as the data format and I will also need to store basics user data for login and their profile.

I wonder how to tackle such a project since so far I have only been using GitHub Pages to host my static websites. Most of what I find by googling seems confusing or irrelevant for such a small-sized project.

My questions are:
What is the simplest way to store, access and edit JSON data as well as user data for a web app?
Are there any simple databases that can be “hosted” together with the app files on a server? Not sure if the question makes sense but I don’t understand where the database is.
What article or resource would you recommend to understand the concepts for data storage?
Ideally you would want to create a backend server using any language/framework e.g nodejs, java, django, php etc and expose the required data through APIs. But, if you don't want to create a separate backend app you can use Firebase database Firestore to save and fetch all of your required data. You can even use firebase hosting to deploy your app. Moreover, firebase also have their Authentication service which you can leverage for your app's authentication.

Do I Need / How do I Set Up Server In My React/Redux/Firestore App?

I am creating a react/redux/firestore app and I understand that react is a frontend library and firestore is a backend nosql database, but how do you add a "server" into the mix of this?
For instance if I wanted to make a query on a bunch of my firestore data to find the average price of an item across tons of records and then use this information to run computational heavy optimizations how would I want to do that in my app? Should I use a server? And if so what and how? Should I just use cloud functions?
Because in theory I could just make a react/redux/firestore app where all of the computation is done in functions in my react frontend with data pulled from firestore but I assume that is not the best way to do things? What should I be doing instead?
TLDR Do I need to offload some computation to a server or cloud functions or something in a react/firestore app? How are things like this usually done or do people just get data from Firestore and then do all of their logic in react? My assumption would be react is just for setting up the ui and button/display functionality, firestore is for storing my data, and something else is where I would do things like find averages based on my firestore data and run optimizations to then pass the answers back to my react frontend to display?
Yes, to try to stay in the firebase ecosystem you could hook Cloud Functions to respond to Firebase events, like onWrite(), onCreate(), etc. Run your heavy computations in there and save that data into the db.
https://firebase.google.com/docs/functions/database-events?hl=es-419

To use React, should I use nodejs (express)?

I plan to build Web application for which the structure is:
My questions are:
Is that correct structure in the commercial?
I plan that FrameWork of Frontend is express(nodejs) at first, but I try to change to django or flask because nodejs is my first use. I wonder if react can be used in this combination.
How about using firebase? You can handle authorization, store and retrieve data. I believe that it will be much easier than any other alternative.
This great article will enable you to implement authentication in few hours. Handling data is also simple, I would use redux as well...

How to make Ionic app work with an API written in Laravel but still works offline

I would like to ask how to create an ionic app that talks to Laravel API but still works offline when there's no connection.
Let's say i have to write a quiz mobile app in Ionic and it requests for Laravel API to retrieve the questions as well as store the scores in db.
I'm just starting to learn Ionic and i'm really confused right now on how to approach this.
What confuses me most are:
Does the Ionic source live inside the Laravel source code w/c serves the API?
If i want the Ionic app to be installable, should the Laravel source code be included as well during the compilation process?
Thanks in advance for any help.
Your php or in general server side code is completely independent from your ionic application. If you want your app to work offline you should think about something like fetching a high number of information initially and work with this data without making any additional requests.
However your ionic app does only contain the frontend. You could implement some logic for local storage, but if you want to keep information hidden from the user (e.g. solutions) you have to put that logic on a dedicated server.
In the few details you provided, I can say the Laravel code does not live inside the ionic app. The ionic app is separate from the backend API by Laravel. You are possibly trying for a ReST based architecture where you communicate with your Laravel Server with an API. You need to keep those codes separate.
However without any internet, you won't be able to access those APIs, so you will just be able to show some static data, or you could serve from a DB and show later. For how to use the sqlite db you can look here
In your backend you can have an API like
http://example.com/api/v1/questions/1/
Which will fetch a question with options and if you want the app to have the answer for offline storage you may have that as well. When a user answers, you may check whether you have internet access and send answer and verify if you do, else you may save the answer in your DB and sync when you do have access. You can fetch multiple questions so that a user may answer multiple questions in case he/she will not have internet access.
Hope it helps. :)

ionic realtime database updates

I'm developing a coffee ordering app using ionic and angularJS and I'm using a mysql database with a laravel backend.
Now i want to check whether a certain order has completed or not in real time. Instead of sending $http requests every second to check with the server is there a way to update the app only when the mysql database gets changed in ionic?
I was told pusher.js does the trick but I have no idea how to integrate it with ionic.
Thank you in advanvce
Using socket should be a best solution for real time updates without repetitive requests from front-end. You can use http://socket.io/ on front-end and on PHP backend as mentioned at http://php.net/manual/en/function.socket-create.php.

Resources