almhdy24/php-mini-mvc
Composer 安装命令:
composer create-project almhdy24/php-mini-mvc
包简介
Professional PHP Mini MVC Skeleton
README 文档
README
This is a simple, clean, and lightweight MVC (Model-View-Controller) starter kit built specifically for PHP 8+. It is perfect if you want to build a small-to-medium web project without the complexity or weight of a huge framework. It keeps things fast, organized, and easy to understand.
📑 Table of Contents
✨ Features
- 🏗️ Classic MVC Pattern: Clear separation of concerns between logic, data, and presentation.
- 📦 PSR-4 Autoloading: Modern class loading using Composer.
- 🛣️ Custom Router: Lightweight URL routing with support for dynamic parameters (e.g.,
/users/{id}). - 🗄️ Base Model (PDO): Ready-to-use SQLite integration with common CRUD operations.
- 🛡️ Error Handling: Custom exception and error handling for cleaner debugging.
- ⚡ Zero Bloat: Extremely minimal codebase; perfect for rapid prototyping.
🛠️ Tech Stack
- Language: PHP 8+
- Package Manager: Composer
- Database: SQLite (default)
- Architecture: MVC
📥 Installation
-
Clone the repository:
git clone https://github.com/almhdy24/php-mini-mvc.git cd php-mini-mvc -
Install dependencies:
composer install
-
Start the local server:
php -S localhost:8000 -t public
-
Access the application at
http://localhost:8000.
💡 Usage
Adding a New Route
Edit routes/web.php to map URLs to Controllers:
$router->get('/profile', ['ProfileController', 'index'], 'profile');
Creating a Controller
Create a new file in app/Controllers/ extending App\Core\Controller:
namespace App aulControllers; use App\Core\Controller; class ProfileController extends Controller { public function index() { $this->view('profile', ['user' => 'John Doe']); } }
📁 Project Structure
| Path | Description |
|---|---|
/app |
Core application logic (Controllers, Models, Views) |
/config |
Application configuration files |
/public |
Entry point of the application (index.php) |
/routes |
Route definitions |
/storage |
SQLite database file storage |
📜 License
Distributed under the MIT License. See LICENSE for more information.
🔗 Important Links
Built with ❤️ by almhdy24 | View on GitHub
If you find this project useful, please consider giving it a star! 🌟
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-27