PHP REST API

This is a simple PHP REST API from scratch with no framework.

Quick Start

Import the myblog.sql file, change the params in the config/Database.php file to your own

Testing

Categories

Create a Category

{
    "name": "Job"
}
  • Sample Response
{
    "status": true,
    "message": "Category Created"
}

Get all Categories

{
    "status": true,
    "message": "Categories Found",
    "data": [
        {
            "id": "7",
            "name": "Insurance"
        },
        {
            "id": "6",
            "name": "Department"
        },
        {
            "id": "1",
            "name": "Technology"
        },
        {
            "id": "2",
            "name": "Gaming"
        },
        {
            "id": "3",
            "name": "Auto"
        },
        {
            "id": "4",
            "name": "Entertainment"
        },
        {
            "id": "5",
            "name": "Books"
        }
    ]
}

Get a Category

{
    "status": true,
    "message": "Category Found",
    "data": {
        "id": "1",
        "name": "Technology"
    }
}

Update a Category

{
    "Key": "Content-Type",
    "Value": "application/json"
}
  • Sample Request
{
    "id": "7",
    "name": "Insurtech"
}
  • Sample Response
{
    "status": true,
    "message": "Category Updated"
}

Delete a Category

{
    "Key": "Content-Type",
    "Value": "application/json"
}
  • Sample Request
{
    "id": "7"
}
  • Sample Response
{
    "status": true,
    "message": "Category Deleted"
}

Search Blog Category

{
    "status": true,
    "message": "Searched Category Found",
    "data": [
        {
            "id": "1",
            "name": "Technology"
        }
    ]
}

Get all Category - Paging

{
    "status": true,
    "message": "Categories Paging",
    "data": [
        {
            "id": "6",
            "name": "Department"
        },
        {
            "id": "1",
            "name": "Technology"
        },
        {
            "id": "2",
            "name": "Gaming"
        },
        {
            "id": "3",
            "name": "Auto"
        },
        {
            "id": "4",
            "name": "Entertainment"
        }
    ]
}

View on Docgen

Task screenshot

Author

Brad Traversy Traversy Media

Sodiq Oyedotun Soyedotun Media

Version

1.0.0

License

This project is licensed under the MIT License