安装部署 3 更新于 2026-10-13

目录结构说明

wenshu-cms/
├── app/                        应用目录
│   ├── admin/                  后台应用(控制器 / 视图 / 路由)
│   ├── api/                    开放接口应用
│   ├── common/                 公共库与标签库
│   │   ├── library/            19 个核心类(Theme / FormBuilder / Seo ...)
│   │   └── taglib/             Cms.php 模板标签库
│   ├── index/                  前台应用
│   └── install/                安装向导
├── config/                     框架与应用配置
├── install/
│   ├── data/
│   │   ├── install.sql         表结构(34 张表)
│   │   └── init.sql            初始化数据(权限节点 / 语言包 / 菜单)
│   └── install.lock            安装锁
├── public/                     Web 根目录
│   ├── index.php               唯一入口
│   ├── static/                 后台静态资源(fontawesome / layui / css / js)
│   ├── theme/<主题>/static/    主题静态资源
│   └── storage/<site_id>/      附件物理存储
├── theme/                      前台模板根目录(按用途分目录)
│   └── default/
│       ├── index/              首页
│       ├── list/               列表页
│       ├── detail/             详情页
│       ├── single/             单页
│       ├── form/               表单
│       ├── tag/                标签页
│       ├── search/             搜索页
│       ├── error/              错误页
│       └── common/             公共片段
├── runtime/                    运行时(缓存 / 日志 / 会话)
└── vendor/                     Composer 依赖

关键目录说明

theme/ 与 public/theme/ 的分工

目录放什么为什么
theme/<主题>/模板文件(.html)不在 Web 根目录下,避免源码被直接下载
public/theme/<主题>/static/css / js / images必须能被浏览器直接访问

模板解析统一走 app/common/library/Theme.php:

Theme::root();       // 主题模板根目录
Theme::locate('list/index');   // 定位模板文件
Theme::templates();  // 列出全部模板
Theme::staticUrl('css/style.css');  // 主题静态资源地址

传给 View::fetch() 的模板名必须以 / 开头(如 /list/index),否则引擎会拼接控制器目录名,报「模板文件不存在」。

runtime/

子目录内容
cache/框架与框架级缓存
log/日志(按天切分)
session/会话文件
admin/、index/、api/各应用的临时目录

⚠️ 在多应用模式下 runtime_path() 会被切换到 runtime/<应用名>/。自定义缓存请显式使用项目根 runtime/<你的名字>/,否则会出现「后台写一份、命令行读另一份」的诡异现象。

public/storage/

附件按 站点 ID / 日期 分层存储:

public/storage/1/20261010/8f3c2a1b....png
public/storage/1/20261010/8f3c2a1b...._thumb.png

访问地址:/storage/1/20261010/8f3c2a1b....png