JVCMS 基于 PHP + MySQL 开发,部署前请确认服务器满足以下条件:
| 项目 | 要求 |
|---|---|
| PHP 版本 | PHP 8.0 ~ PHP 8.5(推荐 PHP 8.5) |
| 数据库 | MySQL 5.7 |
| Web 服务器 | Nginx / Apache / IIS(需支持伪静态) |
| PHP 扩展 | PDO、pdo_mysql、mbstring、openssl、fileinfo |
部署时请根据服务器类型配置伪静态,具体规则见「伪静态配置」章节。
├── index.php # 前台入口
├── admin.php # 后台入口
├── api.php # 应用市场接口
├── config.php # 数据库配置
├── Application/
│ ├── Controllers/ # 控制器(Web/Admin/Api)
│ ├── Core/ # 内核:Lang、Hook、Setting 等
│ ├── Kernel/Kernel.php # 全局常量与契约定义
│ ├── Models/Repository.php # 数据仓库层
│ ├── Plugin/ # 插件目录
│ └── Template/Engine/ # 模板引擎
├── Template/
│ └── default/ # 默认模板
│ ├── pc/ # PC端模板
│ └── mobile/ # 移动端模板(存在则自动启用)
├── languages/ # 17语言包
└── uploads/ # 上传文件
JVCMS 前台采用伪静态路由,支持语言前缀(如 /en/list/4.html):
| URL 格式 | 说明 |
|---|---|
| /list/{id}.html | 分类列表页(第1页) |
| /list/{id}/{page}.html | 分类列表页(第N页) |
| /article/{id}.html | 文章详情页 |
| /download/{id}.html | 下载详情页 |
| /search.html?keyword=xx | 搜索页 |
| /tags/{tag}.html | TAG聚合页 |
模板中使用 {jv:url} 前缀标签自动生成带语言前缀的链接,例如:
<a href="{jv:url}list/4.html">列表页</a>
<a href="{jv:url}article/123.html">详情页</a>
请根据服务器类型选择对应的一组伪静态规则,保存到相应配置文件后重载 Web 服务。IIS / Windows 需先安装 URL Rewrite 模块。
Nginx:写入站点 server 段内,或单独的伪静态配置文件。
# Nginx 伪静态
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
}
}
rewrite ^/[a-z][a-z]/index\.php$ /index.php last;
rewrite ^/[a-z][a-z]-[A-Z][A-Z]/index\.php$ /index.php last;
Apache:保存为网站根目录下的 .htaccess 文件。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^[a-z][a-z]/index\.php$ index.php [QSA,L]
RewriteRule ^[a-z][a-z]-[A-Z][A-Z]/index\.php$ index.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
IIS / Windows:保存为网站根目录下的 web.config 文件。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="JVCMS Lang Index" stopProcessing="true">
<match url="^[a-z][a-z]/index\.php$" />
<action type="Rewrite" url="index.php" />
</rule>
<rule name="JVCMS Lang Index Region" stopProcessing="true">
<match url="^[a-z][a-z]-[A-Z][A-Z]/index\.php$" />
<action type="Rewrite" url="index.php" />
</rule>
<rule name="JVCMS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
每个模板存放于 /Template/[模板代号]/ 目录,包含独立的 pc/ 与 mobile/ 子目录。切换模板只需在后台“我的应用”中启用对应模板;当移动端目录存在时,手机访问自动使用 mobile/ 模板,否则回退到 pc/ 模板。
/Template/blog/
├── pc/
│ ├── header.html # 公共头部
│ ├── footer.html # 公共底部
│ ├── index.html # 首页
│ ├── lists_article.html # 文章列表页
│ ├── article.html # 文章详情页
│ └── skin/ # css/js/images 资源
└── mobile/ # 移动端(可选)
模板文件为纯 HTML,不允许包含 PHP 代码,全部数据通过 {jv:...} 标签输出。公共部分使用 include 标签引入:
{jv:include file='header.html' /}
<div class="main">
{jv:artlist typeid="4" loop="10"}
<a href="{jv:arcurl}">{jv:title}</a>
{/jv:artlist}
</div>
{jv:include file='footer.html' /}
系统内置 17 种语言:简体中文、繁體中文、हिन्दी、English、Indonesia、Português、Русский、اردو、Español、日本語、বাংলা、Tiếng Việt、Deutsch、Türkçe、ไทย、Français、한국어。语言包位于 languages/{语言代码}/web.php(前台)与 admin.php(后台)。
模板中通过 lang 标签输出多语言文本:
{jv:lang name='view_more' /}
<!-- languages/en/web.php -->
<?php return ['view_more' => 'View More'];
语言切换器使用 language 循环标签生成:
{jv:language}
<a href="{jv:language_url}">{jv:name}</a>
{/jv:language}
文章/下载/商品详情页可直接使用以下字段别名:
| 标签 | 说明 |
|---|---|
| {jv:field.title /} | 标题 |
| {jv:field.keywords /} | SEO关键词 |
| {jv:field.description /} | SEO描述 |
| {jv:field.content /} | 正文内容 |
| {jv:field.click /} | 点击量 |
| {jv:field.pubdate /} | 发布时间 |
| {jv:field.typename /} | 所属分类名 |
| {jv:field.typeurl /} | 所属分类链接 |
| {jv:field.arcurl /} | 本文链接 |
插件存放于 Application/Plugin/[插件代号]/ 目录,入口文件为 plugin.php。插件通过 Hook 机制挂载到模板钩子点或后台菜单。
Application/Plugin/myplugin/
├── plugin.php # 插件入口(注册钩子/菜单)
├── config.php # 插件信息
└── ... # 业务文件
模板中预留钩子点:
{jv:hook name='footer_ad' /}
# 插件内监听
Hook::add('template_footer_ad', function($html, $data){
return $html . '<div>插件输出</div>';
});
后台菜单集成:插件可注册独立的后台管理页面与左侧导航菜单,通过 AdminController 的插件路由处理 GET/POST 请求。
{jv:pagelist /}