定制 gajah/framework 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

License: MIT PHP Version

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-20