Create API using php is nothing more than returning data as JSON objects. That datas can be retrieved from a database like MySQL or others. In this repo, you'll se how to retrieve datas:
- created directly in the php script
- stored in database.
Every other app built with web front-end framework like Angular, React, etc can use it because it returns JSON datas.
- MySql : database management system
- PHP : programming language used in this repo
Just make sure you have a local web server running on your computer
-
Download this repository
-
Create a folder and rename it
local-api
inside your local webserver folder -
Move all files and folders from the downloaded repository to
locap-api
folder created previously -
From your web browser, past the following url http://localhost/phpmyadmin and go to it
-
From phpmyadmin dashboard, import the file
db.sql
which is insideDatabase
folder. More details aboutdb.sql
here -
Return to your web browser and past the following url in the search bar http://localhost/local-api
After click on the first button, if you get something like this or this, it's fine ! The second button should show other datas.
- I'm using Ubuntu and my local webserver folder is
/var/www/html
. On Windows, I think it'sC:\wamp\www
if you're using Wamp. If you're using something else like laragon, read it's official doc. - Change credentials in the file
shared/connexion.php
with yours to access your database.