Book Management API (PHP MongoDB) - angelzoee/books-api-crud GitHub Wiki

Setup

Requirements:*

  • PHP (8.x recommended)
  • MongoDB extension for PHP
  • Apache (via XAMPP/WAMP or standalone)
  • db.php file with MongoDB connection

Endpoints

  1. Create a Book
  • URL: /create.php
  • Method: POST
  • Headers: Content-Type: application/json
  • Body (JSON): { "title": "The Alchemist", "author": "Paulo Coelho", "year": 1988, "genre": "Adventure" }
  1. Read a Book
  • URL: /read.php
  • Method: GET
  • Headers: Content-Type: application/json
  1. Update a Book
  • URL: /update.php
  • Method: PUT
  • Headers: Content-Type: application/json
  • Body (JSON): { "_id": "682a958baf08c3f289b71236", "title": "To Kill a Mockingbird - Updated" }
  1. Delete a Book
  • URL: /delete.php
  • Method: DELETE
  • Headers: Content-Type: application/json
  • Body (JSON): { "_id": "682c247541497e18c202bcf4" }