SZ-Rust Core — 主框架包
对标 ThinkPHP 8 的 Rust Web 框架核心,基于 axum 0.8 + SZ-ORM。
模块结构
所有模块均已实现并通过测试(v0.2.0 GA 候选)。
| 模块 | 对齐 PHP | 状态 |
|---|---|---|
controller |
app\SzController / app\BaseController |
✅ |
model |
think\Model |
✅ |
relation |
think\Model 关联关系(HasMany/BelongsTo/HasOne/BelongsToMany/Morph) |
✅ |
request |
$this->request->post/get |
✅ |
response |
renderJson/renderSuccess/renderError |
✅ |
middleware |
CORS/Auth/Log/RateLimit/Trace | ✅ |
guard |
NestJS Guard + Spring Security(sz-rust 自研) | ✅ |
hooks |
think-orm Model 钩子(HookDispatcher 16 事件) | ✅ |
multi_app |
auto_multi_app |
✅ |
health |
健康检查端点(K8s liveness/readiness) | ✅ |
static_files |
静态文件路由(tower-http::ServeDir) |
✅ |
error_handler |
404/500 标准化 JSON 响应 | ✅ |
h2 |
HTTP/2 + TLS(think-swoole SSL) |
✅ |
routing |
三层路由机制(属性宏/配置式/约定式) | ✅ |
addons |
addons/ 插件 |
✅ |
router |
with_route |
✅ |
container |
app() 容器 |
✅ |
error |
BaseException |
✅ |
macros |
compact() |
✅ |
config |
config/app.php / database.php |
✅ |
log |
think-logger |
✅ |
server |
think-swoole / think-worker 启动入口 |
✅ |
validate |
think\Validate 数据验证器 |
✅ |
upload |
think\File + think\file\UploadedFile 文件上传 |
✅ |
cache |
think\facade\Cache 缓存 facade |
✅ |
session |
think\facade\Session 会话管理(SessionStore trait + MemorySessionStore) |
✅ |
cookie |
think\Cookie Cookie 管理(CookieJar + CookieOptions) |
✅ |
event |
think\Event 事件系统(Listener/Subscriber/Observer) |
✅ |
env |
think\facade\Env 环境变量管理 |
✅ |
i18n |
think\facade\Lang 多语言国际化 |
✅ |
mail |
think\facade\Mail 邮件抽象(Mailer trait + MemoryMailer) |
✅ |
migration_history |
think migrate 迁移历史表(多方言 DDL + CRUD SQL 生成) |
✅ |
api_version |
API 版本管理(URL/Header/Query 多策略协商) | ✅ |
cache_warmer |
缓存预热管道(部署/启动时预热,串行/并行+超时控制) | ✅ |
debug_page |
Whoops-style 调试页(开发环境 HTML + 生产环境简洁页) | ✅ |