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.
- 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
- Backend: PHP
- Database: MySQL / MariaDB
- Frontend: HTML, CSS, JavaScript
- Environment: XAMPP, WAMP, or any PHP + MySQL host
The API exposes two primary resources:
category— manage categoriespost— manage blog posts with category relations
Standard endpoints include:
GET api/category/read.phpGET api/category/read_single.php?id={id}POST api/category/create.phpPUT api/category/update.phpDELETE api/category/delete.phpGET api/post/read.phpGET api/post/read_single.php?id={id}POST api/post/create.phpPUT api/post/update.phpDELETE api/post/delete.php
api/— endpoint handlers forcategoryandpostconfig/database.php— PDO connection setupmodels/— business logic forcategoryandpostdatabase/schema.sql— schema and seed datafrontend/— static HTML/JS client showcasing the API
- Import
database/schema.sqlinto your MySQL instance. - Update
config/database.phpwith your database credentials. - Serve the project from your local PHP host.
- Access
frontend/index.htmlin a browser or hit the API directly.
- Responses are returned in JSON.
php://inputis used for POST/PUT/DELETE payload handling.- The frontend demo is intentionally lightweight and meant for API validation.
This repository is provided as a minimal PHP API reference and may be extended for production use.