Skip to content

Mke5/php-mvc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP MVC Framework (Educational)

Version: 1.0.0
Date: 2025-06-17
Author: Michael Emmanuel

Overview

A lightweight PHP MVC framework built for educational purposes to demonstrate core architectural patterns and modern PHP development practices.

✨ Key Features

Category Features
Core Framework MVC architecture, Routing System, Active Record ORM
Security Session-based Authentication, Input Validation, CSRF Protection
Developer Tools CLI Tool (Sh), Migration System, Scaffolding Generators
Database PDO Database Abstraction, Query Builder, Migration Management

🚀 Quick Start

Requirements

  • PHP 7.4+ with PDO extension
  • MySQL 5.7+ or MariaDB 10.2+
  • Apache/Nginx with mod_rewrite enabled
  • Composer (for dependency management)

Installation

# Clone repository
git clone https://github.com/Mke5/php-mvc.git

# Navigate to project
cd php-mvc

# Configure environment (copy example)
cp app/core/config.example.php app/core/config.php

# Edit configuration
nano app/core/config.php

Configuration (app/core/config.php)

  • define('DBHOST', 'localhost');
  • define('DBNAME', 'your_database');
  • define('DBUSER', 'root');
  • define('DBPASS', 'password');
  • define('ROOTPATH', '/your/project/path/');

Project Structure

app/
├── Core/               # Framework core components
│   ├── App.php         # Application bootstrap
│   ├── Model.php       # Base Model
│   ├── Controller.php  # Base Controller
│   └── Database.php    # Database connection
├── Controllers/        # Application controllers
├── Models/             # Database models
├── Views/              # Template files
├── migrations/         # Database migration files
└── sh/                 # CLI Tool (Sh)
public/                 # Web root
├── index.php           # Front controller
└── assets/             # Static resources

Sh CLI Tool

Location: app/sh/Sh.php Purpose: Command-line interface for application management

Installation

# Make executable
chmod +x sh.php

# Verify installation
php sh.php help

Command Reference

Database Operations

Command Description

db:create	Creates application database
db:drop	Drops database (with confirmation)
db:migrate	Executes pending migrations

Code Generation

Command Description

make:controller	Creates new controller
make:model	Creates new model with ORM methods
make:migration	Creates database migration file

Migration Syntax

# Create new table
php sh.php make:migration [table_name] [column:type] [options]

# Alter existing table
php sh.php make:migration alter:[table_name] [column:type] [options]

Column Types & Options

Type Description Example Options
string VARCHAR(255) name:string unique, index
text TEXT bio:text -
integer INT user_id:integer Foreign keys
boolean TINYINT(1) is_admin:boolean -
datetime DATETIME created_at:datetime -
float FLOAT price:float -
double DOUBLE rating:double -
enum ENUM(values) role:enum:admin;user -

Foreign Key Example

php sh.php make:migration posts \
    title:string \
    content:text \
    user_id:integer:users

Enum Example

php sh.php make:migration products \
    status:enum:in_stock;out_of_stock;discontinued

🧪 Testing the Application

# Start development server
php -S localhost:8000 -t public

# Run migrations
php sh.php db:create
php sh.php db:migrate

# Access in browser
http://localhost:8000

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published