How to make PHP web application work online and offline? - php

I am new into web development. I have PHP web application which I created using some Rapid Development Tool. For now I can run it on the server with online database and as well i can run it on my local machine with local database (offline, using XAMPP).
The question is: How to make web PHP application that will be:
stored locally
be able to easily update somehow on different devices
will work with online database when internet is here. Once internet is not here, database will be switched to local one.
databases will be synchronized as well
Is there any software that can handle all of this? Or should I do it manually? Since I am new here, I have completely no ideas on how to realize that.

Related

PHP Web App - local and online synced versions

I developed a PHP driven Web App with a MySQL backend. New requirement is to have it available offline too at a client's office, once there is an lnternet connection, the two should sync so that both local and online versions are the same. Any advice on how best to implement this?
I found MySQL database Master-Master Replication helpful.
https://www.linode.com/docs/databases/mysql/configure-master-master-mysql-database-replication
no need to write code

Desktop Application with Client Server Architecture That Syncs with Cloud Database

I have a web app running with PHP and MySQL.
I need to develop a desktop application which will sync data from the cloud DB whenever the client's computer connects to internet. If the client's computer is not connected to the internet, the desktop application will continue to work offline, using the local DB. The local DB is obviously a replica of the cloud DB.
I don't want to use Microsoft c# to create the desktop application. The desktop application needs to be cross platform and should run on Windows, Mac and Linux.
I have used XAMPP to create a local MySQL DB and have achieved the local app to sync with the cloud app. However, there are multiple problems to that approach.
-- Whenever my client's need to install the local app, they need to call me and I have to install XAMPP in their computer, setup the server, setup the local database and prepare it to sync with the cloud database with their account. They obviously aren't tech savvy so they don't know how to do it themselves.
-- If the client formats his computer, they will call me again and again and I have to set it up for them all the time, which isn't scalable in the longer haul.
-- XAMPP doesn't work when there are other processes running and using common ports. Example - Skype, Quickheal and other antivirus software running will prevent the SQL server to start. Sometimes what happens is that even after I have installed the local app, the client will install an antivirus software or some other tool and my local app will stop working on their computer.
Hence, I need to do away with XAMPP and switch to something else.
SQLite is out of question since it is serverless. I don't want to use .NET either. What I am looking for is this
I want to develop the database driven local application and package it somehow. I want to provider an installer file which will automatically install the database server, setup the database and everything else. The client will only login to the system in the local app and he doesn't have to setup any server. All the work that he does will be synced with the cloud server whenever internet connection resumes.
Please note that there is a master slave work involved. The client will have multiple terminal computers using the master system from other terminals and all these terminal computers will use the local database installed in the master computer.
I have tried to illustrate this with a diagram below
What's the best way to go about it?

Drupal 7 to Local Server

I currently work for a company that is developing a web and mobile application. I've been programming for a while now, but am less familiar with web development. I previously had been writing specialized python scripts for the company; they wanted me to transition into developing their web app. The web dev is currently being outsourced, so there aren't employees at the company that are familiar with how the website was developed. The third party is aware of my task, but is not very helpful and would prefer I only make changes locally.
What I need to do :
I need to put the Drupal site onto a local server, so I can make changes without breaking what was previously built or being on the outsourced web server.
Site specs:
Drupal 7.52
mySQL
PHP 5.6.30-1
Apache/2.2.22
My specs:
Windows 10
I have the website files (code and database). I keep encountering the same error, and have tried a number of different solutions and web stacks. When I go to upload our database into phpMyAdmin, I get an error about the database being too large (unzipped, around 118,000 KB, zipped, around 12,000 KB). I have tried a number of workarounds, and keep falling short. I've changed max_allowed_packets, $cfg['UploadDir'], and many more recommendations given here on Stack Overflow.
I've uninstalled everything from my system, so I can just start over from scratch. If anyone can give a set of instructions for how I would take the website files, upload the large database, and then have a copy of the website on a local server, that would be miraculously helpful.
Thank you!
You could use a virtual machine like this project https://www.drupal.org/project/vdd, which has what you need for local development and you will not need to mess up with our local OS

Using my php scripts in Android to access database

I need some major help in setting up my android app to add/receive data to/from my database. I'm using Amazon's RDS service in connection with xampp's phpMyAdmin. I've already successfully connected my DB instance to the database in phpMyAdmin. Also, I've written my php scripts to do basic CRUD (Create, Read, Update, Delete) commands in SQL. I've been following this tutorial.
The problem for me is, in his tutorial he is using strings like this:
private static String url_all_products = "http://api.androidhive.info/android_connect/get_all_products.php";
to run his php scripts in a call to makeHttpRequest(url_all_products). But I don't have my own website to do this and I'm pretty sure I don't need one to do this.
Next, I have a test.php file that does a simple echo statement and it works when I run this in a web browser:
http://localhost/phpfiles/test.php
Which leads me to my second problem. I don't want to use localhost because I need these php files and the ability to retrieve data from the database to be accessible to anyone using my app. This is the sole reason I'm using Amazon's RDS service so my database can be accessed on the cloud.
So how can I use the host address provided to me by Amazon RDS to access the database and where do I store all the php files so I can properly use them in Android the way the tutorial shows? They are currently saved in xampp/htdocs/phpfiles/.
I feel like I'm missing some fundamental understanding of all this and I'm going about it all wrong. If someone can point me in the right direction that would make my day.
It sounds like you don't really need the XAMPP install on your local machine at all. You're hosting this on Amazon and you want it to be available to the internet, so your local computer isn't involved. You can use XAMPP locally for testing and development, but for production use you'll be exclusively on the Amazon RDS cloud.
But I don't have my own website to do this and I'm pretty sure I don't need one to do this.
You may not want a website, but you do want your services hosted on the internet. That's what your RDS instance is for, and technically the tutorial is referring to an API which happens to be exposed through a web page. This is a much better idea than opening MySQL directly to the internet on port 3306.
You'll then use your Amazon host — for which you really should use a FQDN such as api.example.com rather than the IP address, but the IP address will work just fine from a technical aspect.
The files you refer to are on your local XAMPP installation; in the xampp/htdocs/phpfiles/ folder, and need to instead be on the RDS instance.
Then your application accesses the API you expose in those files which return information back to your application.

is it possible to create a system that is connected a website with the same database

Good day. I have a thesis project. it is composed of a webpage created on php and a system using vb.net 2008.
As of now , they are both connected to the same database.
I am wondering if it is possible that if i packaged the system and live the website, will still be connected with one database? Thank you in advance.
If I understand you right (and the question could be better worded), you're asking what happens if you deploy the website on a different server than the one you used to develop it. The short answer is that, unless the machine hosting the database is accessible to the web server host machine, that you would also have to redeploy the database.
In other words, wherever you move the PHP-based website and VB.NET system, they would need to be able to access the machine hosting the database server. Otherwise, I see no issue with them both accessing the same database.

Categories