PHPackages                             toohamster/fleaphp-ex - 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. toohamster/fleaphp-ex

ActiveLibrary[Framework](/categories/framework)

toohamster/fleaphp-ex
=====================

A lightweight PHP framework with MVC architecture, database abstraction layer, and RBAC support

v0.2.5(2mo ago)01↓100%LGPL-2.1-or-laterPHPPHP &gt;=7.4CI passing

Since Feb 25Pushed 2mo agoCompare

[ Source](https://github.com/toohamster/fleaphp-ex)[ Packagist](https://packagist.org/packages/toohamster/fleaphp-ex)[ RSS](/packages/toohamster-fleaphp-ex/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (11)Used By (0)

FleaPHP 博客系统
============

[](#fleaphp-博客系统)

一个基于 FleaPHP 框架开发的博客系统，演示了框架的核心功能。

功能特性
----

[](#功能特性)

- ✅ 文章列表展示（分页）
- ✅ 文章详情查看
- ✅ 创建新文章
- ✅ 编辑文章
- ✅ 删除文章
- ✅ 评论功能
- ✅ 响应式设计

环境要求
----

[](#环境要求)

- **PHP**: 7.4+
- **MySQL**: 5.0+
- **Composer**: 依赖管理

安装步骤
----

[](#安装步骤)

### 1. 克隆项目

[](#1-克隆项目)

```
git clone
cd fleaphp-ex
```

### 2. 安装依赖

[](#2-安装依赖)

```
php74 ~/bin/composer.phar install
```

### 3. 创建数据库

[](#3-创建数据库)

```
mysql -u root -p  [
    'driver' => 'mysql',
    'host' => '127.0.0.1',
    'port' => '3306',
    'login' => 'root',
    'password' => '11111111',  // 修改为你的密码
    'database' => 'blog',
    'charset' => 'utf8mb4',
],
```

### 5. 设置缓存目录权限

[](#5-设置缓存目录权限)

```
chmod -R 777 cache/
```

### 6. 启动开发服务器

[](#6-启动开发服务器)

```
php74 -S 127.0.0.1:8081
```

### 7. 访问应用

[](#7-访问应用)

打开浏览器访问：

项目结构
----

[](#项目结构)

```
fleaphp-ex/
├── App/
│   ├── Config.php              # 应用配置文件
│   ├── Controller/
│   │   └── PostController.php  # 文章控制器
│   ├── Model/
│   │   ├── Post.php            # 文章模型
│   │   └── Comment.php         # 评论模型
│   └── View/
│       └── post/
│           ├── index.php       # 文章列表页
│           ├── view.php        # 文章详情页
│           ├── create.php      # 创建文章页
│           └── edit.php        # 编辑文章页
├── FLEA/                       # FleaPHP 框架核心
│   ├── FLEA.php               # 框架入口文件
│   └── FLEA/                  # 框架组件
├── cache/                      # 缓存目录
├── vendor/                     # Composer 依赖
├── blog.sql                    # 数据库初始化脚本
├── composer.json               # Composer 配置
├── index.php                   # 应用入口文件
├── USER_GUIDE.md               # 用户手册
├── SPEC.md                     # 框架规格说明
└── README.md                   # 本文件

```

使用说明
----

[](#使用说明)

### 访问首页（文章列表）

[](#访问首页文章列表)

```
http://127.0.0.1:8081/index.php
或
http://127.0.0.1:8081/index.php?controller=Post&action=index

```

### 查看文章详情

[](#查看文章详情)

```
http://127.0.0.1:8081/index.php?controller=Post&action=view&id=1

```

### 创建文章

[](#创建文章)

```
http://127.0.0.1:8081/index.php?controller=Post&action=create

```

### 编辑文章

[](#编辑文章)

```
http://127.0.0.1:8081/index.php?controller=Post&action=edit&id=1

```

### 删除文章

[](#删除文章)

```
http://127.0.0.1:8081/index.php?controller=Post&action=delete&id=1

```

数据库表结构
------

[](#数据库表结构)

### posts (文章表)

[](#posts-文章表)

字段类型说明idINT PRIMARY KEY主键titleVARCHAR(255)文章标题contentTEXT文章内容authorVARCHAR(100)作者created\_atDATETIME创建时间updated\_atDATETIME更新时间statusTINYINT状态 (0-草稿，1-发布)### comments (评论表)

[](#comments-评论表)

字段类型说明idINT PRIMARY KEY主键post\_idINT文章 ID (外键)authorVARCHAR(100)评论者emailVARCHAR(255)邮箱contentTEXT评论内容created\_atDATETIME创建时间statusTINYINT状态 (0-待审核，1-已审核)开发指南
----

[](#开发指南)

### 添加新的控制器

[](#添加新的控制器)

在 `App/Controller/` 目录下创建新的控制器类：

```
