乐于分享
好东西不私藏

Tera 模板引擎最佳实践可执行实战指南:构建可生产部署的 Rust Web 应用

Tera 模板引擎最佳实践可执行实战指南:构建可生产部署的 Rust Web 应用

本文从工程化视角,系统阐述 Tera 在 Rust Web 应用开发中的最佳实践。涵盖全局单例模板管理、安全的可选属性处理、动态模板包含、性能优化、安全性配置、测试策略、单文件部署及与 Axum/ Actix Web 框架的完整集成,以可执行的代码示例呈现一套可直接复用的生产级方案。

一、项目管理最佳实践

1.1 Cargo.toml 性能优先配置

Tera v1 中,启用 builtins 特性会引入所有内置过滤器及其依赖。最佳实践是按需加载,仅注册实际需要的过滤器:

[dependencies]tera = { version = "1.20", default-features = false }  # 禁用 builtins 功能once_cell = "1.19"serde = { version = "1.0", features = ["derive" ] }# 仅添加实际需要的依赖,精确控制slug = "0.1"          # 仅当需要 slugify 过滤器时添加

1.2 全局单例实现

重点说明: 编译模板是一个开销较大的过程,应当只在应用启动时执行一次。使用 once_cell 或 lazy_static 将 Tera 实例声明为全局静态变量,确保模板只被解析一次,是提升生产环境性能的最有效手段。

将模板管理逻辑封装在独立的 templates.rs 模块中:

// src/templates.rsuse once_cell::sync::Lazy;use tera::{TeraContext};pub static TEMPLATES: Lazy<Tera> = Lazy::new(|| {    let mut tera = Tera::new("templates/**/*.html").expect("加载模板失败");    register_custom_extensions(&mut tera);    configure_autoescape(&mut tera);    tera});// 全局辅助函数,简化调用pub fnrender(template_name: &str, context: &Context) -> String{    TEMPLATES.render(template_name, context).unwrap()}// 自定义扩展注册(过滤器和函数在此统一管理)fnregister_custom_extensions(tera: &mut Tera{    // 所有自定义过滤器/函数在模块内部集中注册}fnconfigure_autoescape(tera: &mut Tera{    // 安全配置详见第五章    tera.autoescape_on(vec![".html"".htm"".xml"]);}

1.3 结构化模板目录组织

templates/├── base.html                 # 基础布局模板├── error.html                # 通用错误页面├── pages/                    # 完整页面模板│   ├── index.html│   ├── about.html│   └── contact.html├── partials/                 # 可复用局部片段│   ├── header.html│   ├── footer.html│   └── sidebar.html├── macros/                   # Tera 宏定义文件│   ├── pagination.html│   ├── forms.html│   └── card.html├── emails/                   # 邮件模板(HTML格式)│   ├── welcome.html│   └── reset_password.html└── components/               # UI 组件    ├── alert.html    └── modal.html

二、模板语法与结构最佳实践

2.1 统一 Import 位置与命名空间管理

将所有 {% import %} 语句集中放在模板文件的最开始部分,并为导入的模板指定有意义的别名,避免命名冲突:

{# templates/pages/index.html #}{% import "macros/pagination.html" as pagination %}{% import "macros/forms.html" as forms %}{% import "components/alert.html" as alert %}{% extends "base.html" %}{% block content %}    {# 使用命名空间调用 #}    {{ forms::input(name="username", label="用户名") }}    {{ pagination::render(current_page=1, total_pages=10) }}    {{ alert::info(message="操作成功") }}{% endblock %}

2.2 基础布局模板规范

在 templates/base.html 中,为每个 {% block %} 提供合理的默认内容,并预留必要的 meta block:

<!DOCTYPE html><htmllang="zh-CN"><head>    <metacharset="UTF-8">    <metaname="viewport"content="width=device-width, initial-scale=1.0">    <metaname="description"content="{% block description %}站点描述{% endblock %}">    <title>{% block title %}站点名称{% endblock %}</title>    {% block extra_head %}{% endblock %}</head><body>    {% include "partials/header.html" ignore missing %}    <mainclass="container">        {% block content %}{% endblock %}    </main>    {% include "partials/footer.html" ignore missing %}</body></html>

2.3 安全获取可选属性

在模板中直接访问可能不存在的属性会导致渲染错误。最佳实践是使用 get 过滤器或 default 过滤器安全处理:

1. 使用 get 过滤器:

{# 当属性不存在时返回空值,不会报错 #}<p>{{ user | get(key="profile") | get(key="bio") | default(value="暂无简介") }}</p>

2. 使用 default 过滤器组合:

{# 结合 map 和 default 实现可选属性的安全访问 #}<div class="avatar">    <img src="{{ user.avatar | default(value="/static/default-avatar.png") }}" alt="头像"></div>

get 过滤器是处理可选属性的最简洁方案,当属性不存在时返回空值而不会引发渲染错误。

2.4 变量预定义与调试技巧

设置局部变量可以简化复杂逻辑,提升模板可读性:

{% set page_title = config.title | default(value="默认标题") %}{% set is_authenticated = user.id is defined %}{% if is_authenticated %}    <h1>欢迎回来,{{ user.name }}</h1>{% else %}    <h1>{{ page_title }}</h1>{% endif %}

调试时使用 {{ get_context() | json_encode(pretty=true) }} 打印完整的上下文数据,快速定位问题。

三、模板扩展与复用

3.1 宏系统的模块化设计

将可复用的 UI 组件定义为宏,集中存放在 templates/macros/ 目录下:

{# templates/macros/card.html #}{% macro render(title, content, footer=none) %}<divclass="card">    <divclass="card-header">        <h3>{{ title }}</h3>    </div>    <divclass="card-body">        {{ content | safe }}    </div>    {% if footer is defined %}    <divclass="card-footer">        {{ footer }}    </div>    {% endif %}</div>{% endmacro %}{# templates/macros/pagination.html #}{% macro render(current_page, total_pages, base_url) %}<divclass="pagination">    {% if current_page > 1 %}        <ahref="{{ base_url }}?page={{ current_page - 1 }}">« 上一页</a>    {% endif %}    {% for p in range(start=1, end=total_pages + 1) %}        {% if p == current_page %}            <spanclass="active">{{ p }}</span>        {% else %}            <ahref="{{ base_url }}?page={{ p }}">{{ p }}</a>        {% endif %}    {% endfor %}    {% if current_page < total_pages %}        <ahref="{{ base_url }}?page={{ current_page + 1 }}">下一页 »</a>    {% endif %}</div>{% endmacro %}

3.2 动态模板包含的技术方案

Tera 出于安全考虑,禁止使用变量拼接动态包含模板路径(如 {% include "partials/" ~ name ~ ".html" %})。最佳方案是通过自定义函数实现动态模板加载:

// src/templates.rsuse std::collections::HashMap;use once_cell::sync::Lazy;use tera::{TeraValuefrom_valueto_valueResultContext};pub static TEMPLATES: Lazy<Tera> = Lazy::new(|| {    let mut tera = Tera::new("templates/**/*.html").expect("加载模板失败");    // 注册动态模板包含函数    tera.register_function("include_dynamic", include_dynamic);    tera});fninclude_dynamic(args: &HashMap<String, Value>) -> Result<Value{    let template_path = match args.get("template") {        Some(val) => from_value::<String>(val.clone())?,        None => return Err("缺少 template 参数".into()),    };    // 安全校验:仅允许加载 partials/ 和 components/ 下的模板    if !template_path.starts_with("partials/") && !template_path.starts_with("components/") {        return Err("路径不在允许加载的白名单内".into());    }    // 防止目录遍历攻击    let clean_path = template_path.replace("..""").replace("//""/");    let rendered = TEMPLATES.render(&clean_path, &Context::new())?;    Ok(to_value(rendered)?)}

在模板中使用:

{# 根据用户配置动态加载不同的组件 #}{% for component in page.components %}    {{ include_dynamic(template="components/" ~ component ~ ".html") | safe }}{% endfor %}

四、性能优化策略

4.1 模板预加载与缓存

全局单例模型是最核心的性能优化手段。下面分别展示 once_cell 与 lazy_static 两种实现方式:

// ✅ 推荐:once_cell(现代 Rust 模式)static TEMPLATES: Lazy<Tera> = Lazy::new(|| {    Tera::new("templates/**/*.html").unwrap()});// 备选:lazy_static(兼容旧版)#[macro_use]extern crate lazy_static;lazy_static! {    static ref TEMPLATES: Tera = {        Tera::new("templates/**/*.html").unwrap()    };}

每次请求复用同一 Tera 实例,模板仅解析一次。

4.2 空白控制优化

Tera 默认保留模板中的空白字符。在生产环境中,使用 {%- 和 -%} 去除不必要的空白,减小输出体积:

{# 紧凑输出,消除不必要的空白 #}<ul>{%- for item in items -%}    <li>{{ item.name }}</li>{%- endfor -%}</ul>

4.3 严格模式与调试

在开发环境中可启用严格模式,当变量未定义时立即报错,便于快速定位问题。在更复杂的模板中,有时需要变量 set_global 确保值在循环外仍然可用。

#[cfg(debug_assertions)]pub fninit_templates() -> Tera{    let mut tera = Tera::new("templates/**/*.html").unwrap();    // 严格模式:未定义变量触发错误    tera.strict = true;    tera}

五、安全最佳实践

5.1 自动转义配置

Tera 默认对 .html.htm 和 .xml 文件启用自动转义,遵循 OWASP XSS 防护指南

let mut tera = Tera::new("templates/**/*.html")?;// 保持默认转义配置,这是最安全的做法tera.autoescape_on(vec![".html"".htm"".xml"]);// ⚠️ 以下做法不推荐,会降低安全性:// tera.autoescape_on(vec![]);  // 禁用转义

对于需要输出原始 HTML 的场景(如富文本内容),必须使用 safe 过滤器但需经过严格的内容过滤:

{# ✅ 正确:信任的、已经过清理的 HTML 内容 #}{{ trusted_article_content | safe }}{# ❌ 错误:直接输出用户输入而不加审查 #}{{ user_input | safe }}

5.2 动态路径安全校验

使用动态模板包含时,必须对路径进行严格校验:

fn safe_dynamic_include(args: &HashMap<StringValue>) -> Result<Value> {    let template_path = from_value::<String>(args.get("path").unwrap().clone())?;    // 白名单验证    let allowed_prefixes = ["partials/""components/""emails/"];    if !allowed_prefixes.iter().any(|&p| template_path.starts_with(p)) {        return Err("路径不在白名单内".into());    }    // 拒绝目录遍历攻击    if template_path.contains("..") || template_path.contains("\\") {        return Err("路径包含非法字符".into());    }    // 如果路径需要用户登录信息等上下文,则应通过 Context 传递而非直接嵌入模板路径    // 继续渲染...}

5.3 错误处理最佳实践

fn render_template(template_name: &str, context: &Context) -> Result<StringBox<dyn Error>> {    match TEMPLATES.render(template_name, context) {        Ok(html) => Ok(html),        Err(e) => {            tracing::error!("模板渲染失败: {}", e);            // 在生产环境 fallback 到错误模板并记录错误            render_fallback_error(e.template_name(), e.to_string())        }    }}

六、测试策略

6.1 单元测试模板渲染

#[cfg(test)]mod tests {    use super::*;    use tera::Context;    #[test]    fntest_index_template_renders() {        let mut ctx = Context::new();        ctx.insert("title""测试页面");        ctx.insert("items", &vec!["A""B""C"]);        let result = TEMPLATES.render("index.html", &ctx);        assert!(result.is_ok(), "模板渲染失败: {:?}", result.err());        let html = result.unwrap();        assert!(html.contains("测试页面"), "标题未正确渲染");        assert!(html.contains("A"), "列表项缺失");    }    #[test]    fntest_template_with_missing_context() {        // ⚠️ 当 strict 模式为 true 时,缺失键直接导致 ErrorKind::UndefinedVariable 错误。        // 如果团队在 debug_assertions 中启用了 strict 模式,测试中将能捕获此类错误。        let ctx = Context::new();        let result = TEMPLATES.render("index.html", &ctx);        // 在调试模式下,由于变量缺失,渲染应失败        #[cfg(debug_assertions)]        assert!(result.is_err(), "缺失上下文变量应导致渲染失败");    }}

6.2 自定义过滤器的单元测试

#[test]fntest_custom_filter() {    let mut ctx = Context::new();    ctx.insert("price", &1234567);    let result = TEMPLATES.render("test_price.html", &ctx);    assert!(result.is_ok());}

七、部署与发布

7.1 条件编译实现模板嵌入

将模板嵌入二进制文件,实现单文件部署,同时保持开发时的热重载便利性:

// src/templates.rsuse tera::Tera;#[cfg(debug_assertions)]pub fnload_templates() -> Tera{    // 开发环境:从文件系统加载,支持热重载    Tera::new("templates/**/*.html").expect("加载模板失败")}#[cfg(not(debug_assertions))]pub fnload_templates() -> Tera{    use include_dir::{include_dirDir};    static TEMPLATE_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/templates");    let mut tera = Tera::default();    // 一次性添加所有模板,自动处理依赖顺序    let templates: Vec<(&str, &str)> = TEMPLATE_DIR        .find("**/*.html")        .unwrap()        .filter_map(|entry| {            let file = entry.as_file()?;            let name = file.path().to_str()?;            let content = file.contents_utf8()?;            Some((name, content))        })        .collect();    tera.add_raw_templates(templates).expect("加载嵌入模板失败");    tera}

7.2 构建与发布

# 开发模式(使用文件系统模板)cargo run# 生产构建(模板嵌入二进制)cargo build --release# 验证模板已正确嵌入ldd target/release/myapp  # 应无动态依赖

八、Web 框架集成方案

8.1 Axum 全局状态集成

在 Axum 应用中,所有 Handler 共享同一个 Tera 实例:

use axum::{Routerrouting::getextract::Stateresponse::Html};use std::sync::Arc;use crate::templates::{TEMPLATESrender};  // 结合“全局单例”模块中的 render 辅助函数#[tokio::main]async fnmain() {    let app = Router::new()        .route("/"get(home_handler))        .route("/about"get(about_handler))        .with_state(Arc::new(TEMPLATES.clone()));    axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())        .serve(app.into_make_service())        .await        .unwrap();}async fnhome_handler(State(templates): State<Arc<Tera>>) -> Html<String{    let mut ctx = Context::new();    ctx.insert("title""Tera 最佳实践");    ctx.insert("items", &vec!["Rust""Tera""Axum"]);    let rendered = templates.render("index.html", &ctx).unwrap();    Html(rendered)}async fnabout_handler(State(templates): State<Arc<Tera>>) -> Html<String{    let ctx = Context::new();    let rendered = templates.render("about.html", &ctx).unwrap();    Html(rendered)}

8.2 Actix Web 集成方案

在 Actix Web 中,可通过应用状态(App State)实现 Tera 实例共享:

use actix_web::{webAppHttpResponseHttpServerResponder};use std::sync::Mutex;struct AppState {    tera: Mutex<Tera>,}async fnindex(data: web::Data<AppState>) -> implResponder{    let mut ctx = Context::new();    ctx.insert("title""Actix + Tera 示例");    let tera = data.tera.lock().unwrap();    let rendered = tera.render("index.html", &ctx).unwrap();    HttpResponse::Ok().body(rendered)}#[actix_web::main]async fnmain() -> std::io::Result<()> {    let tera = Tera::new("templates/**/*.html").unwrap();    HttpServer::new(move || {        App::new()            .app_data(web::Data::new(AppState {                teraMutex::new(tera.clone()),            }))            .route("/", web::get().to(index))    })    .bind("127.0.0.1:8080")?    .run()    .await}

九、常见问题与解决方案

问题
原因
最佳实践解决方案
模板继承解析错误
父模板未先于子模板加载
使用 add_raw_templates 一次性添加所有模板
可选属性访问错误
直接访问不存在的字段
使用 get 或 default 过滤器
JSON 解析失败
JSON 字段中包含未转义字符
对自由文本字段使用 json_encode 过滤器
日期格式化失败
时间戳单位错误或时区缺失
使用 epoch_seconds 转换并提供 timezone 参数

十、总结

本文系统梳理了 Tera 模板引擎在 Rust Web 应用开发中的工程化最佳实践。核心要点总结如下:

实践领域
关键做法
依赖配置
禁用 builtins 特性,按需注册过滤器
模板加载
全局单例 + once_cell,启动时一次加载
安全性
保持默认自动转义,动态路径添加白名单校验
模板语法
统一 import 位置,使用 get 过滤器处理可选属性
动态包含
通过自定义函数实现,配合白名单路径校验
性能
条件编译在开发/生产环境智能切换模板加载方式
测试
编写模板单元测试,验证渲染正确性
部署
生产环境将模板嵌入二进制,实现单文件部署

遵循上述最佳实践,你可以构建出安全、高性能、易维护的 Tera 模板系统。根据实际项目规模,从本文的实践条目中选择适合的优化策略并加以应用。

无论身在何处

有我不再孤单孤单

长按识别二维码关注我们

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-06-14 19:45:51 HTTP/1.1 GET : https://www.yeyulingfeng.com/a/586133.html
  2. 运行时间 : 0.104023s [ 吞吐率:9.61req/s ] 内存消耗:4,796.43kb 文件加载:145
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=32ee2ec300413afd1afdf93404f2a45e
  1. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/composer/autoload_static.php ( 6.05 KB )
  7. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/ralouphie/getallheaders/src/getallheaders.php ( 1.60 KB )
  10. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  11. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  12. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  13. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  14. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  15. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  16. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  17. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  18. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  19. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/guzzlehttp/guzzle/src/functions_include.php ( 0.16 KB )
  21. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/guzzlehttp/guzzle/src/functions.php ( 5.54 KB )
  22. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  23. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  24. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  25. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/provider.php ( 0.19 KB )
  26. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  27. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  28. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  29. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/common.php ( 0.03 KB )
  30. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  32. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/alipay.php ( 3.59 KB )
  33. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  34. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/app.php ( 0.95 KB )
  35. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/cache.php ( 0.78 KB )
  36. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/console.php ( 0.23 KB )
  37. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/cookie.php ( 0.56 KB )
  38. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/database.php ( 2.48 KB )
  39. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/filesystem.php ( 0.61 KB )
  40. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/lang.php ( 0.91 KB )
  41. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/log.php ( 1.35 KB )
  42. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/middleware.php ( 0.19 KB )
  43. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/route.php ( 1.89 KB )
  44. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/session.php ( 0.57 KB )
  45. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/trace.php ( 0.34 KB )
  46. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/view.php ( 0.82 KB )
  47. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/event.php ( 0.25 KB )
  48. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  49. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/service.php ( 0.13 KB )
  50. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/AppService.php ( 0.26 KB )
  51. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  52. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  53. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  54. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  55. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  56. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/services.php ( 0.14 KB )
  57. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  58. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  59. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  60. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  61. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  62. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  63. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  64. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  65. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  66. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  67. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  68. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  69. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  70. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  71. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  72. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  73. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  74. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  75. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  76. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  77. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  78. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  79. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  80. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  81. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  82. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  83. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  84. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  85. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  86. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  87. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/Request.php ( 0.09 KB )
  88. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  89. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/middleware.php ( 0.25 KB )
  90. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  91. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  92. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  93. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  94. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  95. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  96. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  97. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  98. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  99. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  100. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  101. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  102. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  103. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/route/app.php ( 3.94 KB )
  104. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  105. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  106. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/controller/Index.php ( 9.87 KB )
  108. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/BaseController.php ( 2.05 KB )
  109. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  110. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  111. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  112. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  113. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  114. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  115. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  116. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  117. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  118. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  119. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  120. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  121. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  122. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  123. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  124. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  125. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  126. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  127. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  128. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  129. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  130. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  131. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  132. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  133. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  134. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  135. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/controller/Es.php ( 3.30 KB )
  136. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  137. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  138. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  139. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  140. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  141. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  142. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  143. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  144. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/runtime/temp/c935550e3e8a3a4c27dd94e439343fdf.php ( 31.50 KB )
  145. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000521s ] mysql:host=127.0.0.1;port=3306;dbname=wenku;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000731s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000350s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000307s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000535s ]
  6. SELECT * FROM `set` [ RunTime:0.000232s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000552s ]
  8. SELECT * FROM `article` WHERE `id` = 586133 LIMIT 1 [ RunTime:0.002093s ]
  9. UPDATE `article` SET `lasttime` = 1781437551 WHERE `id` = 586133 [ RunTime:0.011960s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 64 LIMIT 1 [ RunTime:0.000245s ]
  11. SELECT * FROM `article` WHERE `id` < 586133 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000607s ]
  12. SELECT * FROM `article` WHERE `id` > 586133 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000546s ]
  13. SELECT * FROM `article` WHERE `id` < 586133 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001028s ]
  14. SELECT * FROM `article` WHERE `id` < 586133 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.001232s ]
  15. SELECT * FROM `article` WHERE `id` < 586133 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.000754s ]
0.105738s