PHPackages                             dingqing/e-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. dingqing/e-php

ActiveFramework[Framework](/categories/framework)

dingqing/e-php
==============

A Faster Lightweight Full-Stack PHP Framework

1.0.0(7y ago)691MITPHP

Since Jan 9Pushed 3y ago1 watchersCompare

[ Source](https://github.com/dingqing/e-php)[ Packagist](https://packagist.org/packages/dingqing/e-php)[ RSS](/packages/dingqing-e-php/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (3)Versions (1)Used By (0)

web-frame
=========

[](#web-frame)

> 手动实现web框架（PHP）

目录二级目录理解[框架的工作](#%E6%A1%86%E6%9E%B6%E7%9A%84%E5%B7%A5%E4%BD%9C)实现[文件目录](#%E6%96%87%E4%BB%B6%E7%9B%AE%E5%BD%95) 初始化：[框架入口](#%E6%A1%86%E6%9E%B6%E5%85%A5%E5%8F%A3)，[自动加载](#%E8%87%AA%E5%8A%A8%E5%8A%A0%E8%BD%BD)，[错误与异常处理](#%E9%94%99%E8%AF%AF%E4%B8%8E%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86)，[配置加载](#%E9%85%8D%E7%BD%AE%E5%8A%A0%E8%BD%BD)，[服务容器](#%E6%9C%8D%E5%8A%A1%E5%AE%B9%E5%99%A8) 处理请求：[路由](#%E8%B7%AF%E7%94%B1)，MVC，[ORM](#%E5%AF%B9%E8%B1%A1%E5%85%B3%E7%B3%BB%E6%98%A0%E5%B0%84)，视图 测试与工具：[单元测试](#%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95)，[Git钩子](#%E9%92%A9%E5%AD%90)[使用](#%E4%BD%BF%E7%94%A8)---

理解
--

[](#理解)

### 框架的工作

[](#框架的工作)

> 完成“基础设施”建设：方便的路由定义、错误处理、配置管理、服务管理、ORM等等，使得业务开发更加简洁、方便。

---

实现
--

[](#实现)

### 文件目录

[](#文件目录)

目录说明app应用目录.git-hooksgit钩子framework框架public公共资源目录，暴露到万维网tests单元测试.env.example业务配置示例---

### 框架入口

[](#框架入口)

[public/index.php](public/index.php) -&gt; [framework/start.php](framework/start.php)

### 自动加载

[](#自动加载)

[framework/Load.php](framework/Load.php)

类别说明使用`use 命名空间类名`实现调用spl\_autoload\_register()注册自加载函数到\_\_autoload队列中### 错误与异常处理

[](#错误与异常处理)

[framework/hanles/ErrorHandle.php](framework/handles/ErrorHandle.php)

方案作用通过set\_error\_handler()注册错误处理方法处理常规错误register\_shutdown\_function() + error\_get\_last()在脚本终止执行时，处理set\_error\_handler()不能处理的错误，包括：E\_ERROR、 E\_PARSE、 E\_CORE\_ERROR、 E\_CORE\_WARNING、 E\_COMPILE\_ERROR、 E\_COMPILE\_WARNING，以及在调用set\_error\_handler()所在文件中产生的大多数E\_STRICT通过set\_exception\_handler()注册异常处理方法### 配置加载

[](#配置加载)

[framework/hanles/ConfigHandle.php](framework/handles/ConfigHandle.php)

### 服务容器

[](#服务容器)

[framework/Container.php](framework/Container.php)

> 初级版买菜：直接去农户家购买，可能遇到农户没法提供想要的菜，总之出现各种问题，

> 改进版：去菜市场，比如想要买土豆，市场里面有很多农户提供服务。

> 即，增加中间层，将服务方与调用方解耦，农户专注为提供服务，买方去集市获取服务、不用关心服务的实现。

### 路由

[](#路由)

[framework/hanles/RouterHandle.php](framework/handles/RouterHandle.php)

```
├─ router
  ├─ RouterInterface.php
  ├─ General.php      [普通路由]
  ├─ Pathinfo.php     [pathinfo路由]
  ├─ Userdefined.php  [自定义路由]
  ├─ Job.php          [脚本任务路由]
  └─ RouterStart.php  [路由策略入口类]

```

### 对象关系映射

[](#对象关系映射)

[framework/orm/](framework/orm)

> 把对象的链式操作解析成具体的sql语句。

```
├─ orm
  ├─ Interpreter.php    [sql解析器]
  ├─ DB.php             [数据库操作类]
  ├─ Model.php          [数据模型基类]
  └─ db                 [数据库类目录]
    └─ Mysql.php        [mysql实体类]

```

**DB类使用示例**

```
/**
 * DB操作示例
 *
 * findAll
 *
 * @return void
 */
public function dbFindAllDemo()
{
    $where = [
        'id'   => ['>=', 2],
    ];
    $instance = DB::table('user');
    $res      = $instance->where($where)
                         ->orderBy('id asc')
                         ->limit(5)
                         ->findAll(['id','create_at']);
    $sql      = $instance->sql;

    return $res;
}

```

**Model类使用示例**

```
// controller 代码
/**
 * model example
 *
 * @return mixed
 */
public function modelExample()
{
    try {

        DB::beginTransaction();
        $testTableModel = new TestTable();

        // find one data
        $testTableModel->modelFindOneDemo();
        // find all data
        $testTableModel->modelFindAllDemo();
        // save data
        $testTableModel->modelSaveDemo();
        // delete data
        $testTableModel->modelDeleteDemo();
        // update data
        $testTableModel->modelUpdateDemo([
               'nickname' => 'web-frame'
            ]);
        // count data
        $testTableModel->modelCountDemo();

        DB::commit();
        return 'success';

    } catch (Exception $e) {
        DB::rollBack();
        return 'fail';
    }
}

//TestTable model
/**
 * Model操作示例
 *
 * findAll
 *
 * @return void
 */
public function modelFindAllDemo()
{
    $where = [
        'id'   => ['>=', 2],
    ];
    $res = $this->where($where)
                ->orderBy('id asc')
                ->limit(5)
                ->findAll(['id','create_at']);
    $sql = $this->sql;

    return $res;
}

```

### 单元测试

[](#单元测试)

[phpunit断言文档语法参考](https://phpunit.de/manual/current/zh_cn/appendixes.assertions.html)

> 基于phpunit的单元测试。

**如何使用？**

tests目录下编写测试文件，具体参考tests/demo目录下的DemoTest文件,然后运行：

```
 vendor/bin/phpunit

```

测试断言示例：

```
/**
 *　演示测试
 */
public function testDemo()
{
    $this->assertEquals(
        'Hello web-frame',
        // 执行demo模块index控制器hello操作，断言结果是不是等于'Hello web-frame'　
        App::$app->get('demo/index/hello')
    );
}

```

### 钩子

[](#钩子)

目的：规范化项目代码和commit记录。

- 代码规范：配合使用php\_codesniffer，在代码提交前对代码的编码格式进行强制验证。
- commit-msg规范：采用ruanyifeng的commit msg规范，对commit msg进行格式验证，增强git log可读性和便于后期查错和统计log等, 这里使用了[Treri](https://github.com/Treri)的commit-msg脚本。

---

使用
--

[](#使用)

```
nginx配置虚拟主机根目录设置为项目中的public，然后访问虚拟主机地址。

```

###  Health Score

27

—

LowBetter than 46% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2774d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10338054?v=4)[Qing](/maintainers/dingqing)[@dingqing](https://github.com/dingqing)

---

Top Contributors

[![dingqing](https://avatars.githubusercontent.com/u/10338054?v=4)](https://github.com/dingqing "dingqing (67 commits)")

---

Tags

phpweb-framework

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/dingqing-e-php/health.svg)

```
[![Health](https://phpackages.com/badges/dingqing-e-php/health.svg)](https://phpackages.com/packages/dingqing-e-php)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
