PHPackages                             fastd/dobee - 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. [API Development](/categories/api)
4. /
5. fastd/dobee

ActiveProject[API Development](/categories/api)

fastd/dobee
===========

v1.0.0(1mo ago)108501MITPHPPHP &gt;=8.2

Since Feb 1Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/fastdlabs/dobee)[ Packagist](https://packagist.org/packages/fastd/dobee)[ RSS](/packages/fastd-dobee/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (13)Versions (24)Used By (0)

DoBee Framework
===============

[](#dobee-framework)

[![Build Status](https://camo.githubusercontent.com/cc0d32182e6fe4747bfd2d6c15c6afb4574f65bf956334c22d1180c64d697dbf/68747470733a2f2f7472617669732d63692e6f72672f66617374646c6162732f646f6265652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/fastdlabs/dobee)[![PHP Version](https://camo.githubusercontent.com/d840cef9807c8f76051ad687841d67f4d830c84e0d83236968e53124ef6742d5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e322d3838393242462e737667)](https://secure.php.net/)[![Swoole Version](https://camo.githubusercontent.com/2d00866cb1e0d92e3cd2f1bfbeec9b04d43543fac0d4e1eb8bd4b91332c7a646/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73776f6f6c652d253345253345342e352d3838393242462e737667)](http://www.swoole.com/)[![Latest Stable Version](https://camo.githubusercontent.com/215440d58401f3b89fa2a73b0690fa6c718335abb6b317d79e9ffdfe2d85ec5e/68747470733a2f2f706f7365722e707567782e6f72672f66617374642f646f6265652f762f737461626c65)](https://packagist.org/packages/fastd/dobee)[![License](https://camo.githubusercontent.com/65ee6e0ec2a23aad8e9db807af1616844faf734e51cb05707eece4ad5def0984/68747470733a2f2f706f7365722e707567782e6f72672f66617374642f646f6265652f6c6963656e7365)](https://packagist.org/packages/fastd/dobee)

DoBee 是基于 FastD 组件生态构建的高性能 PHP API 框架骨架，完全支持 Swoole 协程运行，提供简洁优雅的开发体验。

✨ 特性
----

[](#-特性)

- 🚀 **高性能** - 基于 Swoole 协程，性能远超传统 PHP-FPM
- 📦 **组件化** - 完全采用 FastD 8.0 组件，松耦合设计
- 🎯 **PSR 标准** - 遵循 PSR-7/11/15/17/18 标准
- 🔧 **简洁配置** - 清晰的配置文件结构，易于理解和扩展
- 🌐 **HTTP 服务** - 支持 Swoole HTTP 服务器和传统 FastCGI
- 💾 **缓存支持** - 集成文件系统、Redis 等多种缓存后端
- 🗄️ **数据库** - 基于 Medoo 的轻量级数据库操作，支持连接池
- 🎭 **中间件** - PSR-15 中间件支持，灵活扩展
- 📡 **事件驱动** - 完整的事件监听器机制

📋 环境要求
------

[](#-环境要求)

- **PHP**: &gt;= 8.2
- **Swoole**: &gt;= 4.5 (可选，用于协程模式)
- **扩展**:
    - ext-swoole (可选)
    - ext-pdo
    - ext-json
    - ext-curl

📦 安装
----

[](#-安装)

### 方式一：使用 Composer 创建项目（推荐）

[](#方式一使用-composer-创建项目推荐)

```
composer create-project fastd/dobee myapp
cd myapp
```

### 方式二：克隆仓库后安装

[](#方式二克隆仓库后安装)

```
git clone https://github.com/fastdlabs/dobee.git
cd dobee
composer install
```

### 方式三：手动添加到现有项目

[](#方式三手动添加到现有项目)

```
composer require fastd/dobee
```

🚀 快速开始
------

[](#-快速开始)

### 1. 项目结构

[](#1-项目结构)

```
myapp/
├── config/              # 配置文件
│   ├── cache.php       # 缓存配置
│   ├── command.php     # 命令配置
│   ├── database.php    # 数据库配置
│   ├── listener.php    # 监听器配置
│   ├── process.php     # 进程配置
│   ├── route.php       # 路由配置
│   ├── service.php     # 服务配置
│   └── swoole.php      # Swoole 配置
├── src/                # 应用代码
│   ├── bootstrap.php   # 引导文件
│   ├── command/        # 控制台命令
│   ├── http/           # HTTP 处理器
│   ├── listener/       # 事件监听器
│   ├── process/        # 自定义进程
│   └── server/         # 服务器监听器
├── tests/              # 测试文件
└── web/                # Web 入口
    └── index.php

```

### 2. 配置数据库

[](#2-配置数据库)

编辑 `config/database.php`:

```
return [
    'default' => [
        'type' => 'mysql',
        'host' => '127.0.0.1',
        'database' => 'dobee',
        'username' => 'root',
        'password' => '',
        'charset' => 'utf8mb4',
        'port' => 3306,
    ],
];
```

### 3. 配置缓存

[](#3-配置缓存)

编辑 `config/cache.php`:

```
return [
    'file' => [
        'adapter' => [
            'class' => \Symfony\Component\Cache\Adapter\FilesystemAdapter::class,
            'dsn' => null,
        ],
        'namespace' => 'dobee',
        'lifetime' => 3600,
        'directory' => __DIR__ . '/../runtime/cache',
    ],
];
```

### 4. 定义路由

[](#4-定义路由)

编辑 `config/route.php`:

```
return [
    ['GET', '/', \http\Welcome::class],
    ['GET', '/users', \http\UserController::class . '@index'],
    ['POST', '/users', \http\UserController::class . '@store'],
];
```

### 5. 创建 HTTP 处理器

[](#5-创建-http-处理器)

创建 `src/http/UserController.php`:

```
