#PHP MVC SYSTEM
Using php to create a coffee sale coffee website
With mvc structure we divide project into many folder:
./bootstrap: contain bootstrap framework.
./font: contain font.
./img: contain img.
./views: contain files to display front-end.
./models: contain php files to deploy back-end.
./controllers: contain php to deploy back-end.
./migrations: update database.
./middlewares: contain middleware.
./core: contain the core classes.
It's a simple php-mvc template version 1.0. We will maintain and develop in future.
- To run php and mysql conveniently together install XAMPP:
- After that install Composer (a PHP package manager):
- Restart computer
- Delete vendor folder if exist
- Check for Composer version:
composer --version
- Install project packages:
composer install
phpMyAdmin config:
If using XAMPP, goto C:\xampp\phpMyAdmin
and edit config.inc.php
the following line:
$cfg['Servers'][$i]['password'] = 'admin';
MySQL Config:
Server host : localhost
Database : ecom
Port : 3306
Username : root
Password : admin
In folder project, create file .env with the following config:
DB_DSN=mysql:host=localhost;dbname=ecom
DB_USER=root
DB_PASSWORD=admin
Turn on XAMPP
- Start Apache
- Start MySQL
In terminal:
php migrations.php
The terminal should return:
[2021-10-28 19:10:49] - Applying migration m0001_initial.php
[2021-10-28 19:10:49] - Applyied migration m0001_initial.php
Else, drop all table in database and re-run migration
To run the project, type the following into the terminal:
cd public
php -S localhost:8000