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:
- WHERE SHOULD I PUT MY PHP FILE IN MY PROJECT FOLDER?
- WHERE SHOULD I CREATE MY QUERIES?
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:
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:
So you have 4 simpe cases:
- you make class based requests:
- object based
- class bases but special action
- object based with special 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?..