Skip to content

JM-Support-sk/Handle-REST-api-incoming-requests-in-PHP

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README

installation

  1. There no special technique, just clone this repository into you local server or development machine
  2. You may set up a virtual host in the web server to run the application
  3. Create a mysql database
  4. Import the .sql file (data/product.sql) in your created database.
  • in order to have a working example, i created a sample product table
  1. Change your database configurations in config/config.php.
  2. Everything is ready to go you can now call a simple api request

API reference

GET request

url: /index.php?api_name=product
description: get all the product lists

GET request

url: /index.php?api_name=product&id=2
description: get the product by its id

POST request

url: /index.php?api_name=product
params in the request body: name, description, price
description: add a new product

DELETE request

url: /index.php?api_name=product&id=2
description: Delete a product by its id

PUT request

url: /index.php?api_name=product&id=2
params in the request body: name, description, price
description: update product

TEST

You can test the api request by using a Postman. It is a chrome tool for the REST client.

About

A simple REST api requests handler in PHP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%