当前位置:首页>python>Typer vs传统CLI:Python开发者的新选择与最佳实践

Typer vs传统CLI:Python开发者的新选择与最佳实践

  • 2026-01-31 19:09:27
Typer vs传统CLI:Python开发者的新选择与最佳实践
基于 Python 类型提示的 CLI 框架,打造用户喜爱、开发者青睐的命令行应用

PART 01

引言:为什么需要 Typer?
在 Python 生态系统中,命令行工具的开发一直是一个重要的领域。从简单的脚本到复杂的企业级工具,CLI(命令行接口)扮演着不可或缺的角色。然而,传统的 CLI 开发方式往往面临着代码冗余、类型安全缺失、文档维护困难等挑战。
Typer 的出现,彻底改变了这一现状。作为由 FastAPI 作者 Sebastián Ramírez 创建的现代化 CLI 框架,Typer 将 Python 的类型提示(Type Hints)与命令行开发完美结合,被誉为"CLI 界的 FastAPI"。

PART 02

核心特性:Typer 的杀手锏
2.1 类型提示驱动
Typer 最大的创新在于充分利用 Python 3.6+ 的类型提示系统。通过函数参数的类型注解,Typer 能够自动生成完整的命令行接口。
import typerdef main(name: str, count: int = 1):    """问候指定次数"""    for _ in range(count):        typer.echo(f"Hello, {name}!")if __name__ == "__main__":    typer.run(main)
2.2 编辑器友好
得益于类型提示,现代 IDE(如 PyCharm、VS Code)能够提供完整的自动补全、类型检查和内联文档支持,大大提升开发效率。
2.3 自动化特性
  • 自动帮助文档生成:基于函数文档字符串自动生成使用说明
  • 自动完成支持:为多种 Shell(bash、zsh、fish 等)生成自动完成脚本
  • 自动类型验证:在运行时验证参数类型,提供清晰的错误信息
2.4 最小化代码
与其他 CLI 框架相比,Typer 的代码量大幅减少。实现相同的功能,代码量可减少 50% 以上。

PART 03

快速开始:3 步打造第一个 CLI
3.1 安装
# 基础安装pip install typer# 完整安装(包括所有依赖)pip install "typer[all]"
3.2 创建最简单的应用
# main.pyimport typerdef main(name: str):    """一个简单的问候程序"""    typer.echo(f"你好, {name}!")if __name__ == "__main__":    typer.run(main)
3.3 运行
# 查看帮助python main.py --help# 执行命令python main.py 张三

PART 04

深入探索:Typer 的强大功能
4.1 命令和子命令
Typer 支持构建复杂的命令树结构,非常适合管理工具和套件。
from typer import Typerapp = Typer()@app.command()def hello(name: str):    """问候命令"""    typer.echo(f"Hello, {name}!")@app.command()def bye(name: str, formal: bool = False):    """告别命令"""    if formal:        typer.echo(f"Goodbye, Ms. {name}.")    else:        typer.echo(f"Bye, {name}!")if __name__ == "__main__":    app()
4.2 参数类型详解
4.2.1 位置参数(Argument)
@app.command()def process_file(filename: str):    """处理指定文件"""    typer.echo(f"正在处理: {filename}")
4.2.2 可选参数(Option)
@app.command()def serve(    host: str = typer.Option("127.0.0.1"help="服务器地址"),    port: int = typer.Option(8000help="端口号"),    debug: bool = typer.Option(Falsehelp="调试模式")):    """启动服务器"""    typer.echo(f"启动服务器: {host}:{port}, 调试={debug}")
4.2.3 高级类型支持
from typing import ListOptionalfrom pathlib import Path@app.command()def analyze(    files: List[Path] = typer.Argument(..., help="要分析的文件列表"),    output: Optional[Path] = typer.Option(Nonehelp="输出文件"),    verbose: int = typer.Option(0"--verbose""-v", count=True)):    """分析文件"""    for file in files:        typer.echo(f"分析: {file}")
4.3 命令分组
# 主应用main_app = Typer(help="我的工具集")# 数据库子命令组db_app = Typer(help="数据库操作")main_app.add_typer(db_app, name="db")@db_app.command()def init():    """初始化数据库"""    typer.echo("数据库初始化完成")@db_app.command()def migrate():    """执行数据库迁移"""    typer.echo("数据库迁移完成")# 用户子命令组user_app = Typer(help="用户管理")main_app.add_typer(user_app, name="user")@user_app.command()def create(username: str):    """创建用户"""    typer.echo(f"用户 {username} 创建成功")if __name__ == "__main__":    main_app()
4.4 Rich 集成
Typer 深度集成了 Rich 库,提供精美的终端输出。
from typer import Typerfrom rich.console import Consolefrom rich.table import Tablefrom rich.progress import Progressapp = Typer()console = Console()@app.command()def show_data():    """以表格形式展示数据"""    table = Table(title="项目列表")    table.add_column("名称", style="cyan")    table.add_column("状态", style="magenta")    table.add_column("进度", justify="right", style="green")    table.add_row("项目A""进行中""75%")    table.add_row("项目B""已完成""100%")    table.add_row("项目C""待开始""0%")    console.print(table)@app.command()def process():    """带进度条的处理"""    with Progress() as progress:        task = progress.add_task("[green]处理中...", total=100)        while not progress.finished:            progress.update(task, advance=1)    console.print("[bold green]处理完成![/bold green]")

PART 05

框架对比:Typer vs 其他选择
特性
Typer
Click
argparse
Docopt
学习曲线
代码量
最少
较少
较多
中等
类型安全
自动补全
编辑器支持
优秀
良好
较差
较差
子命令支持
文档自动生成
优秀
良好
一般
优秀
5.1 代码对比示例
使用 argparse:
import argparseparser = argparse.ArgumentParser(description='文件处理工具')parser.add_argument('input_file'help='输入文件')parser.add_argument('--output''-o'help='输出文件', default=None)parser.add_argument('--verbose''-v', action='store_true'help='详细模式')args = parser.parse_args()if args.verbose:    print(f"处理文件: {args.input_file}")if args.output:    print(f"输出到: {args.output}")
使用 Typer:
import typerdef process(    input_file: str,    output: str = typer.Option(None"--output""-o"),    verbose: bool = typer.Option(False"--verbose""-v")):    """处理文件"""    if verbose:        typer.echo(f"处理文件: {input_file}")    if output:        typer.echo(f"输出到: {output}")if __name__ == "__main__":    typer.run(process)

PART 06

实际应用场景
6.1 数据处理管道
from typer import Typerfrom typing import Listimport pandas as pdapp = Typer(help="数据处理工具")@app.command()def process_csv(    input_file: str,    output_file: str,    columns: List[str] = typer.Option(None"--col"help="选择列"),    filter_col: str = typer.Option(Nonehelp="过滤列"),    filter_value: str = typer.Option(Nonehelp="过滤值")):    """处理CSV文件"""    df = pd.read_csv(input_file)    if columns:        df = df[columns]    if filter_col and filter_value:        df = df[df[filter_col] == filter_value]    df.to_csv(output_file, index=False)    typer.echo(f"处理完成,输出到: {output_file}")
6.2 DevOps 工具
from typer import Typer, Contextfrom pathlib import Pathimport subprocessapp = Typer(help="部署工具")@app.callback()def callback(ctx: Context, env: str = "dev"):    """全局配置"""    ctx.ensure_object(dict)    ctx.obj['env'] = env@app.command()def build(ctx: Context):    """构建项目"""    env = ctx.obj['env']    typer.echo(f"在 {env} 环境下构建...")    # 执行构建命令    subprocess.run(["docker""build""-t"f"myapp:{env}""."])@app.command()def deploy(ctx: Context, server: str = typer.Option(..., help="目标服务器")):    """部署项目"""    env = ctx.obj['env']    typer.echo(f"部署到 {env} 环境的 {server} 服务器...")    # 执行部署逻辑    pass@app.command()def rollback(ctx: Context, version: str = typer.Option(..., help="回滚版本")):    """回滚版本"""    env = ctx.obj['env']    typer.echo(f"在 {env} 环境下回滚到版本 {version}...")    # 执行回滚逻辑    pass
6.3 API 客户端
from typer import Typerimport requestsapp = Typer(help="API客户端工具")BASE_URL = "https://api.example.com"@app.command()def list_users(limit: int = 10):    """列出用户"""    response = requests.get(f"{BASE_URL}/users", params={"limit": limit})    users = response.json()    for user in users:        typer.echo(f"ID: {user['id']}, Name: {user['name']}")@app.command()def get_user(user_id: int):    """获取用户详情"""    response = requests.get(f"{BASE_URL}/users/{user_id}")    user = response.json()    typer.echo(f"用户: {user['name']}")    typer.echo(f"邮箱: {user['email']}")@app.command()def create_user(name: str, email: str):    """创建用户"""    response = requests.post(        f"{BASE_URL}/users",        json={"name": name, "email": email}    )    user = response.json()    typer.echo(f"用户创建成功: ID {user['id']}")

PART 07

最佳实践
7.1 项目结构建议
my-cli-tool/├── my_cli/│   ├── init.py│   ├── main.py          # 主入口│   ├── commands/        # 命令模块│   │   ├── init.py│   │   ├── db.py        # 数据库命令│   │   └── user.py      # 用户命令│   ├── utils.py         # 工具函数│   └── config.py        # 配置管理├── tests/               # 测试├── setup.py             # 安装配置└── README.md            # 文档
7.2 命名规范
  • 应用名称:使用小写和下划线,如 `my_cli`
  • 命令名称:使用动词或动词短语,如 `list`, `create-user`
  • 选项名称:使用完整单词或通用缩写,如 `--verbose`, `-v`
7.3 错误处理
from typer import Exit@app.command()def risky_operation(force: bool = False):    """有风险的操作"""    try:        # 执行操作        pass    except FileNotFoundError:        typer.echo("错误: 文件不存在", err=True)        raise Exit(code=1)    except PermissionError:        typer.echo("错误: 权限不足", err=True)        if not force:            raise Exit(code=1)        # 强制执行
7.4 测试策略
from typer.testing import CliRunnerfrom my_cli.main import apprunner = CliRunner()def test_hello():    result = runner.invoke(app, ["hello""张三"])    assert result.exit_code == 0    assert "Hello, 张三!" in result.stdoutdef test_bye_formal():    result = runner.invoke(app, ["bye""李四""--formal"])    assert result.exit_code == 0    assert "Goodbye, Ms. 李四." in result.stdout

PART 08

高级特性
8.1 自定义验证器
def validate_age(value: int):    if value < 0 or value > 120:        raise typer.BadParameter("年龄必须在 0-120 之间")    return value@app.command()def register(age: int = typer.Option(..., callback=validate_age)):    """注册用户"""    typer.echo(f"注册成功,年龄: {age}")
8.2 回调函数
def check_options(ctx: typer.Context):    if ctx.obj.get("verbose"):        typer.echo("详细模式已启用")@app.command()def process(    verbose: bool = typer.Option(False, callback=check_options)):    """处理数据"""    typer.echo("处理完成")
8.3 Shell 自动完成
生成自动完成脚本:
# Bashpython main.py --install-completion bash# Zshpython main.py --install-completion zsh# Fishpython main.py --install-completion fish
8.4 多语言支持
@app.command()def greet(    name: str,    lang: str = typer.Option("zh"help="语言: zh/en/es")):    """多语言问候"""    greetings = {        "zh"f"你好, {name}!",        "en"f"Hello, {name}!",        "es"f"¡Hola, {name}!"    }    typer.echo(greetings.get(lang, greetings["zh"]))

PART 09

生产环境建议
9.1 打包发布
# setup.pyfrom setuptools import setup, find_packagessetup(    name="my-cli-tool",    version="0.1.0",    packages=find_packages(),    install_requires=[        "typer[all]>=0.7.0",    ],    entry_points={        "console_scripts": [            "mycli=my_cli.main:app",        ],    },)
9.2 配置管理
import configparserfrom pathlib import Pathdef load_config():    config = configparser.ConfigParser()    config_path = Path.home() / ".config" / "mycli" / "config.ini"    if config_path.exists():        config.read(config_path)    return config@app.command()def run():    """运行命令"""    config = load_config()    # 使用配置
9.3 日志记录
import loggingdef setup_logging(verbose: bool):    level = logging.DEBUG if verbose else logging.INFO    logging.basicConfig(        level=level,        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'    )@app.command()def process(verbose: bool = False):    """处理数据"""    setup_logging(verbose)    logger = logging.getLogger(__name__)    logger.info("开始处理...")    logger.debug("调试信息")

PART 10

总结与展望
Typer 作为新一代 Python CLI 框架,凭借其简洁的 API、强大的类型支持和优秀的开发者体验,正在快速改变命令行工具的开发方式。
核心优势
  1. 开发效率提升 50% 以上:代码量大幅减少,专注于业务逻辑
  2. 类型安全:充分利用 Python 类型系统,减少运行时错误
  3. 用户体验优秀:自动生成帮助文档和 Shell 补全
  4. 社区活跃:FastAPI 生态的延续,持续的更新和维护
适用场景
  • ✅ 需要快速开发的命令行工具
  • ✅ 复杂的多命令管理工具
  • ✅ DevOps 和系统管理脚本
  • ✅ API 客户端和数据处理工具
  • ✅ 需要良好用户体验的商业工具
未来展望
随着 Python 类型系统的不断完善和开发工具的进步,Typer 将继续引领 CLI 开发的潮流。未来可能的发展方向包括:
  • 更丰富的类型支持
  • 更强大的插件系统
  • 更好的 Web 集成能力
  • 原生的异步支持

PART 11

结语
Typer 让命令行工具的开发变得更加优雅、高效和愉悦。无论你是构建简单的脚本还是复杂的企业级工具,Typer 都能提供强大的支持。现在就开始使用 Typer,体验现代化的 CLI 开发吧!
相关资源:
  • 📚 官方文档:https://typer.tiangolo.com/
  • 💻 GitHub 仓库:https://github.com/tiangolo/typer
  • 🐛 问题反馈:https://github.com/tiangolo/typer/issues
  • 📖 中文文档:https://typer.fastapi.org.cn
    专注于 Python 生态和开发者工具。欢迎关注微信公众号获取更多技术干货!

最新文章

随机文章

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