Skip to content

rhodevanwyk/PHP_REST_API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP REST API

A minimal blog API built with pure PHP, PDO, and MySQL. This project demonstrates clean REST endpoint design, relational data handling, and a lightweight browser client for CRUD operations.

iPad Pro

Features

  • Category and post CRUD through JSON endpoints
  • Relational post queries with category metadata
  • PDO database access with prepared statements
  • Minimal frontend demo using vanilla JavaScript
  • CORS-friendly API design for easy integration
  • Simple MVC-style separation with models, configuration, and API handlers

Tech Stack

  • Backend: PHP
  • Database: MySQL / MariaDB
  • Frontend: HTML, CSS, JavaScript
  • Environment: XAMPP, WAMP, or any PHP + MySQL host

API Overview

The API exposes two primary resources:

  • category — manage categories
  • post — manage blog posts with category relations

Standard endpoints include:

  • GET api/category/read.php
  • GET api/category/read_single.php?id={id}
  • POST api/category/create.php
  • PUT api/category/update.php
  • DELETE api/category/delete.php
  • GET api/post/read.php
  • GET api/post/read_single.php?id={id}
  • POST api/post/create.php
  • PUT api/post/update.php
  • DELETE api/post/delete.php

Project Structure

  • api/ — endpoint handlers for category and post
  • config/database.php — PDO connection setup
  • models/ — business logic for category and post
  • database/schema.sql — schema and seed data
  • frontend/ — static HTML/JS client showcasing the API

Setup

  1. Import database/schema.sql into your MySQL instance.
  2. Update config/database.php with your database credentials.
  3. Serve the project from your local PHP host.
  4. Access frontend/index.html in a browser or hit the API directly.

Notes

  • Responses are returned in JSON.
  • php://input is used for POST/PUT/DELETE payload handling.
  • The frontend demo is intentionally lightweight and meant for API validation.

License

This repository is provided as a minimal PHP API reference and may be extended for production use.

About

A plain PHP REST API for a simple blog (posts and categories), built with no frameworks, just PHP, MySQL, and a bit of HTML / CSS / JS for a frontend 'test' page. I made this to study how REST APIs work. (P.S...This isn't production level ready.)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors