Skip to content

CheapStudent/php-api-assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

PHP API Assignment

A simple RESTful API for managing products inventory built with pure PHP.

Features

  • Create new products (POST /api/products)
  • Get all products (GET /api/products)
  • Get specific product by ID (GET /api/products/{id})
  • Update existing products (PUT /api/products/{id})

API Endpoints

Create Product

  • POST /api/products
  • Body: JSON with product data
  • Example:
    {
      "name": "Test Product",
      "description": "Test description",
      "price": 99.99,
      "quantity": 10
    }
    

Get All Products

-> GET /PHP-API-Ass/data/products.json

Get Single Product

-> GET /PHP-API-Ass/api/products/{id}

Update Product

-> PUT /PHP-API-Ass/api/products/{id} -> Body: JSON with fields to update

Setup Instructions

  1. XAMPP Setup: -> Download and install XAMPP -> Start Apache server

  2. Project Setup: ->Clone this repository to htdocs folder: C:\xampp\htdocs\PHP-API-Ass
    -> Ensure the data/ directory is writable

  3. API Testing -> Use Postman or curl to test the endpoints -> API Base URL: http://localhost/PHP-API-Ass/api/

Technical Details:-

-> Build with pure PHP (no frameworks) -> JSON file-based storage -> Propeer error handling and validation -> Restful API design patterns

Developer:-

Ravindra Gupta

File Structure:-

PHP-API-Ass/
├── api/
│ ├── config.php
│ └── products.php
├── data/
│ └── products.json
├── .htaccess
└── README.md 

About

A simple RESTful API built with pure PHP for managing product inventory using JSON file storage.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published