A simple blog application built using a custom PHP MVC (Model-View-Controller) framework.
This project is beginner-friendly and ideal for learning PHP OOP, routing, authentication, and CRUD operations.
- β Custom MVC framework (no external dependencies)
- β User registration and login
- β Post CRUD (Create, Read, Update, Delete)
- β Session-based authentication
- β MySQL database integration
- β Clean file structure for easy understanding
project/
βββ assets/ # For css/js/images
β βββ css
β βββ style.css
β βββ js
β βββ images
β
βββ config/ # Database config
β βββ database.php
β
βββ controllers/ # Controller classes
β βββ AuthController.php
β βββ PostController.php
β
βββ core/ # Core framework (MVC base)
β βββ App.php
β βββ Controller.php
β βββ Model.php
β
βββ models/ # Model classes
β βββ User.php
β βββ Post.php
β
βββ views/ # View files (HTML/PHP)
β βββ auth/
β βββ post/
β βββ layouts/
β
βββ index.php # Entry point
- PHP 7.4 or higher
- MySQL or MariaDB
- Apache or Nginx
- Clone the repo
git clone https://github.com/rawbinn/basic-mvc-structure-using-php.git
cd basic-mvc-structure-using-php
-
Create the database and tables You can find sql in migrations directory
-
Configure database connection
Edit config/database.php:
<?php
return [
'host' => 'localhost',
'username' => 'root',
'password' => '', // set your DB password
'database' => 'your_database_name'
];
- Run the app Place the project in your web serverβs root directory (e.g., htdocs for XAMPP) Start Apache/MySQL
Visit: http://localhost/basic-mvc-structure-using-php/index.php
π§ͺ Demo Routes Feature URL
Home /index.php
Register /index.php?url=auth/register
Login /index.php?url=auth/login
Post List /index.php?url=post/index
Create Post /index.php?url=post/create
Edit Post /index.php?url=post/edit/1