/E-com-221

Test deploy heroky

Primary LanguagePHP

#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.

SET UP

Installation

  1. To run php and mysql conveniently together install XAMPP:
  2. After that install Composer (a PHP package manager):
  3. Restart computer
  4. Delete vendor folder if exist
  5. Check for Composer version:
composer --version
  1. Install project packages:
composer install

Generating MySQL Database:

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

Creating dotenv

In folder project, create file .env with the following config:

DB_DSN=mysql:host=localhost;dbname=ecom
DB_USER=root
DB_PASSWORD=admin

Run MySQL DBMS

Turn on XAMPP

  • Start Apache
  • Start MySQL

Run migration:

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

Run project

To run the project, type the following into the terminal:

cd public
php -S localhost:8000