Simple MVC Framework With PHP

Chibuzo Miracle
2 min readAug 16, 2022

--

Sometimes in 2018, I was introduced into the world of Object Oriented Programming (OOP), the first challenge I had was to come up with an MVC (Model-View-Controller) Framework that wouldn't compromise the standards of OOP and still permit functional programing to an extent.

In this article I will walk you through a simple but yet efficient MVC file structure. This tutorial is not for absolute beginners in PHP.

For this tutorial, you’ll need the following tools

  1. A code editor or a PHP IDE
  2. basic knowledge of OOP in PHP

Folder structure

Firstly, create a folder structure that looks like this.

The app folder: This folder will hold our models, controllers and helper functions

bootstrap folder: This will hold the required logic to pass data around the application

config folder: This will hold all application configuration files

public folder: This contains the index.php file which is the primary and only entrance into the application an also will contain our static files.

routes folder: This will contain our routing files

views folder: as the name implies, this folder will contain our view files

.htaccess file: .htaccess is a plain text configuration file for the Apache HTTP Server that allows administrators to specify options for directories where web content is served. The initial “.” in .htaccess means that the file will be invisible on Unix-like systems in directory listings except with the “ls -a” command. credit techopedia.

Part 2 (Bootstrapping): https://medium.com/@miraclechibuzo/simple-mvc-framework-with-php-bootstrapping-aedb48826fc4

--

--

Chibuzo Miracle

B Eng A&B Engineering || Software Developer || Technical Writer