A lightweight, modern PHP MVC (Model-View-Controller) framework with integrated DataTables server-side processing, Bootstrap 4 UI, and comprehensive user management system.
- MVC Architecture: Clean separation of concerns with Model-View-Controller pattern
- Server-Side DataTables: Efficient handling of large datasets with AJAX pagination, sorting, and filtering
- User Authentication: Complete user management system with role-based access control
- Bootstrap 4: Modern, responsive UI components
- Security Features:
- HTTPS detection (proxy/load balancer compatible)
- SQL injection protection
- CSRF token validation
- Password hashing
- Database Integration: PDO-based database abstraction layer
- Export Functionality: Export data to CSV, Excel, PDF, and Print
- Real-time Updates: Auto-refresh DataTables with AJAX
- Session Management: Secure user session handling
- PHP >= 7.4 (PHP 8.0+ recommended)
- MySQL >= 5.7 or MariaDB >= 10.2
- Apache/Nginx web server with mod_rewrite enabled
- Composer (optional, for dependency management)
git clone https://github.com/elightsys/PHP-MVC-03.git
cd PHP-MVC-03Import the database schema:
mysql -u your_username -p your_database_name < mysql.sqlCopy the example configuration file and update it with your settings:
cp app/config/config.php.example app/config/config.phpEdit app/config/config.php and update the following:
// Database credentials
define('__DB_HOST__', 'localhost');
define('__DB_USER__', 'your_db_username');
define('__DB_PASS__', 'your_db_password');
define('__DB_NAME__', 'your_db_name');
// Generate a unique security key
define('__UNIQID__', md5(uniqid(rand(), true)));chmod -R 755 public/
chmod -R 777 storage/logs/ storage/cache/The .htaccess file is already included. Make sure mod_rewrite is enabled:
sudo a2enmod rewrite
sudo service apache2 restartAdd this to your server block:
location / {
try_files $uri $uri/ /public/index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
}Navigate to: http://your-domain.com/public/
Default login credentials (change immediately after first login):
- Email:
admin@example.com - Password:
admin123
PHP-MVC-03/
βββ app/
β βββ config/
β β βββ config.php.example # Configuration template
β β βββ config.php # Your config (git-ignored)
β βββ controllers/ # Application controllers
β β βββ Pages.php
β β βββ Users.php
β β βββ Admin.php
β βββ models/ # Data models
β β βββ SspModel.php
β β βββ AdminModel.php
β βββ views/ # View templates
β β βββ pages/
β β βββ admin/
β β βββ _inc/
β βββ libraries/ # Core libraries
β β βββ Core.php
β β βββ Controller.php
β β βββ Database.php
β β βββ Ssp.php
β βββ helpers/ # Helper functions
β βββ autoload.php # Autoloader
βββ public/ # Public web directory
β βββ index.php # Front controller
β βββ assets/ # CSS, JS, images
β βββ uploads/ # User uploads
βββ mysql.sql # Database schema
βββ .gitignore
βββ .htaccess
βββ LICENSE
βββ README.md
Routes are automatically mapped to controllers:
http://your-domain.com/public/Pages/Users
β β
Controller Method
<?php
class YourController extends Controller {
public function index() {
$data = [
'title' => 'Your Page Title'
];
$this->view('your-view', $data);
}
}The framework includes a powerful DataTables SSP (Server-Side Processing) implementation:
public function SspUsersDT() {
if (isset($_POST['draw'])) {
exit(self::$sspModel->sspUserDT($_POST));
}
}$this->db->query('SELECT * FROM users WHERE active = :active');
$this->db->bind(':active', 1);
$results = $this->db->resultSet();The framework automatically detects HTTPS connections, even behind proxies and load balancers:
// Checks multiple sources for HTTPS
- $_SERVER['HTTPS']
- $_SERVER['HTTP_X_FORWARDED_PROTO']
- $_SERVER['HTTP_X_FORWARDED_SSL']
- $_SERVER['SERVER_PORT']All database queries use PDO prepared statements:
$this->db->query('SELECT * FROM users WHERE email = :email');
$this->db->bind(':email', $email);Forms include CSRF tokens:
$timestamp = time();
$token = md5('unique_salt' . $timestamp);- Server-Side Processing: Handle millions of records efficiently
- AJAX Pagination: Smooth, fast pagination without page reloads
- Search & Filter: Real-time search across all columns
- Sorting: Multi-column sorting
- Export Options: CSV, Excel, PDF, Print
- Responsive Design: Mobile-friendly tables
- Auto-refresh: Configurable auto-refresh interval
Contributions are welcome! Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
- DataTables - Table plugin for jQuery
- Bootstrap - CSS framework
- Font Awesome - Icon library
- jQuery - JavaScript library
- GitHub: @elightsys
- Project Link: https://github.com/elightsys/PHP-MVC-03
Please check the Issues page for known bugs and feature requests.
For more detailed documentation, please visit the Wiki.
Note: This is a learning/demonstration project. For production use, consider additional security measures, comprehensive testing, and regular updates.