This is a lightweight PHP MVC framework built from scratch, designed to help you quickly build web applications following the Model-View-Controller (MVC) architecture. The framework supports dynamic routing, database interaction with MySQL, and uses environment variables to manage sensitive configuration details.
- Lightweight custom MVC structure
- Dynamic routing (supports GET and POST routes)
- Environment variable support via
.envfile - Database interaction (MySQL)
- Simple session flashing for error and success messages
- Composer autoload for organizing classes and files
Follow these steps to set up and run the project locally:
git clone https://github.com/xinodeprinz/php-mvc.git
cd php-mvcSince we're using Composer for autoloading classes, you need to generate the autoloader and install node.js dependencies:
composer dump-autoload
npm installRename the .env.example file to .env, and then set up your database credentials and other configuration values.
DB_HOST=localhost
DB_NAME=your_database_name
DB_USER=your_database_user
DB_PASSWORD=your_database_passwordRun the following command to start a local PHP and Tailwind CSS compilation servers:
npm startNow, you can visit the app in your browser at http://localhost:2500.
/app
/Controllers
/Models
/Views
/core
/Database
/Router.php
/Env.php
/public
/index.php
/.env
composer.json
Feel free to fork this repository, create issues, or submit pull requests. Contributions and improvements are highly welcome!