Files
ulthon_admin/extend/ua/build/BuildDoc.md
2025-08-09 21:58:18 +08:00

105 lines
2.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 核心需求
**将FrankenPHP + ThinkPHP应用打包成单一二进制文件支持一行命令启动多种服务**
## 详细要求
### 1. 打包方式
- 使用FrankenPHP的embed机制将ThinkPHP代码打包到Go二进制文件中
- 最终产出一个独立的可执行文件包含所有ThinkPHP代码和依赖
- 支持跨平台编译Linux和Windows
### 2. 服务启动模式
```bash
# Linux
./frankphp serve -daemon -port 8080
# Windows
frankphp.exe serve -daemon -port 8080
```
**一行命令同时启动:**
- FrankenPHP的PHP-FPM模式HTTP服务器
- ThinkPHP应用程序如Workerman等Worker进程
- 进入后台守护进程模式
### 3. 命令系统支持
**系统管理命令:**
- `serve` - 启动所有服务
- `stop` - 停止守护进程
- `restart` - 重启服务
- `status` - 查看运行状态
- `version` - 版本信息
- `install` - 安装为系统自动启动服务
- `uninstall` - 卸载系统自动启动服务
**ThinkPHP框架命令**
- 支持think命令`./frankphp make:controller`, `./frankphp migrate:run`
- 支持自定义命令:`./frankphp my-command --option=value`
- 直接执行PHP脚本`./frankphp php script.php`
### 4. 守护进程特性
- 后台运行
- PID文件管理
- 信号处理SIGTERM, SIGHUP等
- 进程监控和重启机制
### 5. 多服务并发运行
- **HTTP服务**FrankenPHP处理ThinkPHP Web请求
- **Worker服务**运行Workerman等长驻进程
- 所有服务在同一进程中并发运行
### 6. 自动启动服务管理
**Linux系统**
- 生成systemd服务文件
- 支持`systemctl enable/disable`
- 开机自动启动
**Windows系统**
- 注册为Windows服务
- 支持服务管理器控制
- 开机自动启动
### 7. ThinkPHP框架集成
- 支持ThinkPHP的think命令行工具
- 兼容ThinkPHP的目录结构
- 支持ThinkPHP的配置文件
- 集成ThinkPHP的命令系统
### 8. 技术实现细节
- 使用Go的`embed`包嵌入ThinkPHP文件
- 运行时提取文件到临时目录
- 使用goroutine并发管理多个服务
- 跨平台的服务安装/卸载实现
- 统一的日志输出和错误处理
### 9. 部署便利性
- 单文件部署无需PHP环境
- 跨平台编译支持Linux/Windows
- 支持系统服务管理
- 一键安装自动启动
- 一行命令启动完整应用栈
### 10. 使用示例
```bash
# 构建
./build.sh
# 启动服务
./frankphp serve -daemon -port 8080
# ThinkPHP命令
./frankphp make:controller User
./frankphp migrate:run
# 安装为系统服务
sudo ./frankphp install
# 卸载系统服务
sudo ./frankphp uninstall
# Windows下
frankphp.exe install
frankphp.exe uninstall
```
**核心价值将ThinkPHP应用环境HTTP服务器 + Worker进程 + 命令行工具)打包成一个跨平台的独立二进制文件,支持系统服务管理和一键部署。**