How to connect Azure SQL with my IONIC App using PHP

I have an Azure SQL Server, I created it from dbForge since SQL Server Management Studio won’t have database designers for Azure SQL.

Right now, I want to create a PHP Script to be my backend service. Here are my Qs:


Pls help me out.

first your backend (API) has nothing to do in your frontend project folder (maybe you can work with git submodules).

You have to separate them!
With php you have to create an API --> you are defining endpoints like GET /users --> if someone calls yourDomain.tld/users you should retrurn the users.

You php api is connected to your database and gets, inserts, updates, deletes your data according to which endpoint gets called.

In a really simple example you only need 1 php file:

Your endpoints are like: GET /index.php?class=user
In your script you can check first, which request type it is (get, put, post, delete, head, …)
After that you can check which class --> and then you know ahh okay the client wants all users --> get them

if you need multiple get actions on users --> like i want a specific one, could be this:
GET /index.php?class=user&id=USERID
know you can check if there is an id-parameter --> ah okay the user wants a special user and not all

And if that is not enough, like you want to get something special of a user you can make this:
GET /index.php?class=user&id=USERID&action=SPECIAL

So you have 4 simpe cases:

  1. you make class based requests:
    GET,DELETE,PUT,… /index.php?class=CLASSNAME
  2. object based
    GET,DELETE,PUT,… /index.php?class=CLASSNAME&id=ID
  3. class bases but special action
    GET,DELETE,PUT,… /index.php?class=CLASSNAME&action=ACTION
  4. object based with special action
    GET,DELETE,PUT,… /index.php?class=CLASSNAME&id=ID&action=ACTION

It is not that beautiful but maybe you can an idea --> with this approach you have a generic api-endpoint definition.

In your ionic app you can use the $http-service to send simple requests.

And if you are ready --> add an .htaccess to your backend and enable mod_rewrite --> with some simple settings you can make beautiful rest-urls
and redirect them to index.php?..