A lightweight API-driven application built using Native PHP. This project aims to teach PHP without a framework, demonstrating a clear separation between:
- API Server – Handles database operations and returns JSON response
- Client App – Consumes API via cURL and renders data in HTML views
The goal is to understand and implement RESTful API architecture, cURL-based HTTP requests, and modular MVC structure without frameworks.
- MVC-like structure (Controller, Views, CurlClient)
- Consume API via cURL (GET, POST, PUT, DELETE)
- Modal-based CRUD (Create, Read, Update, Delete)
- Clean route handling (
web.php?action=...) - Redirect, form request handling, and dynamic response
- RESTful API in Native PHP
- JSON responses with HTTP status codes
- Endpoint-based structure (
users/index.php,users/create.php, etc.) - PDO-based database access
- Password hashing for secure user storage
belajar-php-native/
│
├── api-server/
│ ├── config/
│ │ └── database.php
│ └── endpoints/
│ └── users/
│ ├── index.php # GET all users
│ ├── show.php # GET single user
│ ├── create.php # POST - create user
│ ├── update.php # PUT - update user
│ └── delete.php # DELETE - delete user
│
├── client-app/
│ ├── config/
│ │ └── api_config.php
│ ├── controllers/
│ │ └── UsersController.php
│ ├── core/
│ │ └── CurlClient.php # Handles cURL API Requests
│ ├── views/
│ │ └── users/
│ │ ├── index.php # Main UI (CRUD modal-based)
│ │ ├── create.php # (optional)
│ │ └── edit.php # (optional)
│ ├── routes/
│ │ └── web.php # Basic Routing
│ └── index.php # Entry point
│
└── README.md
| Layer | Technology |
|---|---|
| Client Application | Native PHP, HTML, Modal-based UI |
| API Communication | PHP cURL |
| API Response Format | JSON (REST) |
| Database | MySQL (via PDO) |
| Server Stack | Apache (Laragon/XAMPP) |
git clone https://github.com/your-username/php-api-client-architecture.git
cd php-api-client-architectureapi-server/config/database.php
$host = "localhost";
$db_name = "your_database";
$username = "root";
$password = "";client-app/config/api_config.php
define("API_BASE_URL", "http://localhost/belajar-php-native/api-server/endpoints/");extension=curlRestart Apache/Laragon after enabling.
http://localhost/belajar-php-native/api-server/endpoints/users/index.php
http://localhost/belajar-php-native/client-app/
Auto loads UsersController@index Displays users table with modal-based CRUD
- 🔐 Authentication with token-based login (JWT / OAuth)
- ⚠ Server-side validation and error handling
- 📄 Pagination and search
- 📁 File upload via API (image/avatar)
- ⚛ Migration to AJAX (Single Page API Client)
- 🧱 Refactor toward mini PHP MVC Framework
MIT License. Free to use, modify, and improve.
Muhammad Farras Subahan Web Developer & API Learner 🚀 Focus: Native PHP, API Architecture, Laravel, Next.js
"Frameworks come later. Foundation always comes first."