Connect react native to an existing php and mysql project - php

So I currently have a website built with PHP and MySQL that is hosted by a provider similar to GoDaddy (called "XSERVER" or "エックスサーバー").
I've been trying to connect the MySQL server to a react-native project so that I could GET and POST information from my app, but I haven't had any luck.
The hosting company does not allow node.js to be run on their servers, so the option of express.js was eliminated.
what other option could I take to connect a PHP and MySQL server to a react-native app?
Sorry for the general and ambiguous question, I genuinely don't know who to ask or if I should give up.
The website: https://kasumushi.com/

You have many options to create an API with MySQL and PHP. This API can then be used in your React native application. You should incorporate some sort of auth mechanism to be sure that only your react app can interact with the API.
Either create one from scratch, or use a REST API framework

Related

Connect React Native app to a laravel web app with MySQL Database

I'm currently building a new project that needs a web app and mobile app and i'm forced to work with Laravel and React Native.
So my question is if I can connect between the two app's using MySQL ?
PS: I already searched and i did find this topic here, but i didn't get the idea clear.
Laravel can be just a backend and React-Native is a front-end. Your React-Native can talk to a Laravel backend without any problem or can share a database such as MySQL, it is no different then using a Node, ASP.NET, Ruby or even a Perl backend for your React-Native app to serve a REST API and connect to a database.
Not knowing the details of your website, I would look to build a REST API that can be used by React, React-Native (iOS android, or both) and the laravel based website. Certain features like authentication should easily work cross platform, other API calls may need to be tailored to Mobile vs Web. The backend can be Laravel or any other system include Node as long as it is a REST API, both the site and app will be able to use it.

How can I connect to my MySQL database backend through Android without exposing it to the public?

I've made an app for Android that uses the Retrofit HTTP API to call PHP scripts which query a database.
App -> Retrofit Call -> PHP -> Database
The PHP and the database are both hosted on the same Amazon EC2 instance.
I would like my app to be deployable to many users, but I don't know how to keep my backend private.
In order for the app to interact with the database, it must use the PHP and since users' IP addresses will vary, I have to keep that PHP code's host's IP address public so that all users can submit/download data.
The problem is that this leaves my backend open to anyone who wants to sniff out the IP address. How can I get around this issue? Is PHP/MySQL a bad choice for Android, or have I simply chosen the wrong platforms?
The best solution will be if you create an API backend for your app that in turn talks to your app-server and database. This is the standard practice of creating mobile applications that have cloud backends
AWS API Gateway would be a perfect fit for it. This is very cheap, responsive and a secure service.
Is encryption out of the question? You can encrypt/decrypt strings or data between android and PHP.
Some codes that I used can be found here: https://stackoverflow.com/a/20929131/7199177
You might have created APIs using PHP
You can develop the following mechanism using the PHP to secure your APIs:
list out the API which should be public like login, signup so anyone can access it.
All other APP should be accessible after a some authentication only.
Your APIs should be talking to your Database server which is in a private subnet.
Other options:
Use API-Gateway with Lambda and your Database server:
To reduce the use of API-gateway you can directly write a code in lambda and use aws-sdk in your application to call lambda. In backend use your database server.

Mobile App - Communicating with an external server

I'm building a mobile project that needs to be in constant communication with a server and i need some information . I know how to build local apps but this is the first time that i'm building an app that requires external call to a server / authentication service .
I'm asking for guidance how to proceed and which services/servers to use.
What type of server/database do i need ?
I'm guessing i will be requiring an API service but no idea how to choose/make one.
I want to use azure services/database but i also don't want to be dependent on it. I want to have my own url that i send request to and interact with a server/db that i can later move to another host fairly easily.
I develop websites mostly and i'm familiar with php/laravel + Mysql but i think in this case it will be overkill to create a laravel app simply for the server backend .
The app will be mobile only so i don't expect to have a webpage for it . simply an external server/database where the data will be saved.
First i need an authentication service - where each user will register on the phone which will then be saved in my external server/database . Then when they need to login - they will input the login details on the phone , which will query the esternal server/database and if validated - get their details from the server.
First, you need to decide which kind of server communication you'll need. it's in real time and constant? then you'll need a websocket. It's in bursts when you need to send or get data? then you'll need some kind of webservice (REST, RPC, SOAP). Then you have to evaluate the user load you'll have. And finally, the human resources you'll have.
Based on your question, I think a REST webservice will be more than enough. You may:
-Create a REST service for every group of related resources. Example: the /user URL should handle the signup, login, logout and user update operations.
-Create a method for each one of those operations and handle them. Then, call the method from the REST service class.
-Depending on the amount of users and the technology you're using, create a server to handle the requests, or upload your REST project to a server (tomcat, for example).
-Create an app and consume the REST services from there.
There are tons of tech you can choose for these things. PHP allows creating REST services, I think. Java is a very good choice too, since you can use the same code in both server and android apps. Node.Js is pretty popular, too, since you don't need servers and uses NIO (althought java can do both things using jetty and also has multithreading); golang and scala both have superb performance (golang is a lot more easier to learn, though, and it has no need to use external webservers).
Hope this helps.
For mobile applications the best will be REST (representational state transfer),becouse is lightweight and flex to use in other technology. I had project which include REST and mobile app and web app and it working very well.
In this scenario, we usually will build a REST API service for client end. As you are familiar with Laravel, you can refer to http://www.programmableweb.com/news/how-to-build-restful-apis-using-php-and-laravel/how-to/2014/08/13#apiu for how to build a REST API service with Laravel. Also you can leverage other light 3rd part PHP frameworks to build REST API service.
You can create and develop the application on local and then deploy to Azure Web Apps. Please refer to https://azure.microsoft.com/en-us/documentation/articles/app-service-web-php-get-started/ for more info.
And there several vendors provide MySQL services on Azure. ClearDB is a BaaS on Azure for MySQL. You also can use the VM to host your MySQL Service. E.G. MySQL by Bitnami and MySQL by Docker.

Share database between app and web

I'm involved into an app that have to retrieve queries from an existing database. This db have to be implemented in php in a remote server, and will be the place where the admin will have to insert content into the shared db, but I don't know how to implement that correctly or what is the best solution.
I'm thinking about make a sqlite database with php and connect directly the app to the db, but I haven't found yet the best way to do that.
What do you think? Thank guys.
FYI, without any server communication (Web services) you can't use the website database in android application.
If you want to manage the communication between the website and the android app means you need a centralized server (probably my sql dab) which having the data of your web/mobile applications. So, after that by using the web service methods (REST/SOAP) you can achieve the communication between them
I'm thinking about make a sqlite database with php and connect
directly the app to the db, but I haven't found yet the best way to do
that.
This is not the right approach to connect mobile applications with the database. Instead you should create a middleware(REST/SOAP webservice) which runs on server. This middleware will in turn connect with the database and your mobile app whether it is android, iOS or windows app can communicate with this middleware.

Different database for GAE

How to use another database for Google App engine than the datastore. And if it could be possible to access it with php(quercus).
Not in practical terms. Datastore is the only supported database at the moment.
You could have a database on another server and access it via RPC (REST, WebService), but this would not be an integrated approach and would add more work to the project. For example you could set up a MySql server somewhere and use phprestsql to setup a REST interface and then acces it from GAE.
#Peter Knego
i am also looking for same. I want to host my java web application on GAE and databse on different Server(Godaddy).
Google data store is free for only 6 months, So i would like to use database of different hosting(goDaddy). So is it possibe??
I am able to use database of my hosting(goDaddy) from my local system but when i upload my application to GAE that it doesn't work. I know it is possible in case of other servers but what about GAE.

Categories