Skip to content

Favour919/php-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

REST API with Basic CRUD Operation

This is a REST API with basic CRUD operation. It is built with PHP and MySQL 8.0.30. It is a simple API that can be used to create, read, update and delete 'person' resource.

Table of Contents

Usage

Add a new person.

Request:

POST /api
Content-Type: application/json

{
  "name": "John Doe"
}

Response:

Status: 200 OK
Content-Type: application/json

[
  {
    "id": 1,
    "name": "John Doe"
  }
]

Fetching details of a person.

Request:

GET /api/{id}

Response:

Status: 200 OK
Content-Type: application/json

{
  "id": 1,
  "name": "John Doe",
}

Updating details of a person.

Request:

PUT /api/{id}
Content-Type: application/json

{
  "name": "Updated User",
}

Response:

Status: 200 OK
Content-Type: application/json

{
  "id": 1,
  "name": "Updated User"
}

Deleting a person.

Request:

DELETE /api/{id}

Response:

Status: 204 No Content

Note: Replace {id} in the URLs with the actual ID of the user you want to retrieve, update, or delete.

Error Handling

The API returns the following in case of an error:

Status: Error Code
Content-Type: application/json

{
    "error": "Error Message"
}

Testing

  • Postman was used to test the API. The collection of the test requests can be found here:

    Run in Postman

UML Diagram

UML

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages