gajah/framework
最新稳定版本:v1.0.0
Composer 安装命令:
composer require gajah/framework
包简介
A simple and lightweight PHP web framework with clean structure and easy routing
关键字:
README 文档
README
A lightweight and simple PHP web framework with clean MVC architecture and easy-to-use routing system.
Features
- Simple Routing - Easy GET/POST routing with controller actions
- MVC Architecture - Organized Controllers, Views, and configuration
- Lightweight - Minimal dependencies, fast to learn and implement
- PSR-4 Autoloading - Modern PHP autoloading standards
- Clean Structure - Well-organized directory structure for scalable projects
- PHP 7.4+ - Compatible with modern PHP versions
Installation
Via Composer
composer require rifaldo-dev/gajah
Create Project
composer create-project rifaldo-dev/gajah my-app
cd my-app
Manual Clone
git clone https://github.com/Rifaldo-dev/gajah
cd gajah
composer install
Quick Start
1. Start Development Server
cd public
php -S localhost:8000
2. Add a Route
Edit config/routes.php:
$router->add('/about', 'AboutController@index'); $router->add('/contact', 'ContactController@index');
3. Create a Controller
Create app/controllers/AboutController.php:
<?php class AboutController { public function index() { Router::view('about/index', [ 'title' => 'About Us' ]); } }
4. Create a View
Create app/views/about/index.php:
<!DOCTYPE html> <html> <head> <title><?= $title ?></title> </head> <body> <h1><?= $title ?></h1> <p>Welcome to our about page!</p> </body> </html>
Directory Structure
gajah/
├── public/ # Web root - entry point for browser
│ ├── index.php # Application entry file
│ └── .htaccess # URL rewriting configuration
├── app/ # Application code
│ ├── controllers/ # Application controllers
│ └── views/ # Application views/templates
├── config/ # Configuration files
│ ├── config.php # Application configuration
│ └── routes.php # Route definitions
├── src/ # Framework core
│ └── Router.php # Router engine
├── storage/ # Storage directory
│ ├── cache/ # Cache files
│ └── logs/ # Log files
├── composer.json # Composer configuration
├── LICENSE # MIT License
└── README.md # This file
Usage
Routing
// GET route $router->get('/path', 'ControllerName@method'); // POST route $router->post('/path', 'ControllerName@method'); // Both GET and POST $router->add('/path', 'ControllerName@method');
Rendering Views
// Without data Router::view('page/index'); // With data Router::view('page/index', [ 'title' => 'Hello', 'message' => 'World' ]);
Configuration
Edit config/config.php to change:
define('APP_NAME', 'My App'); define('APP_ENV', 'development'); define('APP_DEBUG', true);
Requirements
- PHP >= 7.4
- Apache with mod_rewrite (or equivalent URL rewriting)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
For issues and questions, please visit GitHub Issues.
Changelog
See CHANGELOG.md for all version history and changes.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-20