# panel **Repository Path**: fiberphp/panel ## Basic Information - **Project Name**: panel - **Description**: 🎛️ FiberPHP 管理面板基础组件 —— 提供通用后台 UI 组件、权限骨架、API 路由基类,是 crontab-panel 和 queue-panel 的公共依赖库。 - **Primary Language**: PHP - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-08-30 - **Last Updated**: 2026-11-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # fiberphp/panel FiberPHP 管理后台 HTTP Server 骨架 —— 供 [queue-panel](https://gitee.com/fiberphp/queue-panel) / [crontab-panel](https://gitee.com/fiberphp/crontab-panel) 复用的公共层。 ## 职责 | 能力 | 说明 | |---------------|------------------------------------------------------------------------------------------------| | 静态资源服务 | 服务 `ui_path` 下的单页 Dashboard,SPA fallback,目录穿越防护 | | ETag 协商缓存 | `Cache-Control: no-cache` + 304(文件更新立即生效,未变免重传) | | token 鉴权 | `admin_token`(`X-Admin-Token` 头或 `?token=` 查询参数),`hash_equals` 恒时比较,未配置不鉴权 | | JSON 输出 | 统一 `code/msg/data` 结构 + CORS 头 | | 请求 scope | 每请求开启协程 Context scope,确保 `onDestroy`(连接归还等)正确触发 | ## 用法 继承 `AbstractAdminHttpServer`,实现 4 个抽象方法: ```php use FiberPHP\Panel\AbstractAdminHttpServer; class HttpServer extends AbstractAdminHttpServer { protected function configSection(): string // 独立配置段 { return 'queue_panel'; } protected function serverName(): string // 启动输出显示名 { return 'Queue admin'; } protected function defaultListen(): string // 未配置 listen 时的默认地址 { return 'http://0.0.0.0:18889'; } protected function handleApi(TcpConnection $connection, Request $request, string $method, string $path): void { // 鉴权(/api/health GET 除外)→ 业务路由 → sendJson() } } ``` 鉴权约定:除 `GET /api/health` 外所有 API 均需 token;静态资源与 UI 不鉴权。 ## License MIT