simple CRUD rest api with slim php and mysql
-
first check if you have
php >= 7
,mysql
andcomposer
installed -
create a database in sql and execute the querys in the
books.sql
file to create the table. -
change database config in
configDB.php
. -
Install the dependencies with:
composer install
-
After previous steps, open the api folder in terminal and start the server with the command:
php -S localhost:4000
GET /books
GET /books/{id}
POST /books
and send the body with the json in this format:
{
title: String, (required)
author: String,
book_description: string
}
PUT /books
and send the body with the json in this format:
{
id: int, (required),
title: String, (required)
author: String,
book_description: string
}
DELETE /books/{id}