tumtum/sw6-sql-logger

将 SQL 查询返回到浏览器或 cli。

v1.1.0 2023-08-03 11:20 UTC

This package is auto-updated.

Last update: 2024-09-03 13:39:23 UTC


README

将所有 SQL 查询返回到浏览器或 cli 的控制台。

安装

composer require --dev tumtum/sw6-sql-logger

用法

只需在某处设置函数 StartSQLLog(),从那时起所有 SQL 将被记录。

\StartSQLLog();

$criteria = new Criteria();
$result = $this->productRepository->search($criteria, Context::createDefaultContext());

\StopSQLLog();

与 VarDumper::dump() 的用法

如果您想将 SQL 语句输出到 VarDumper::dump() 并将结果输出到 HTML 文件,可以使用以下步骤

配置 Shopware 6(一次性)

# config/packages/dev/debug.yml
debug:
    dump_destination: tcp://%env(VAR_DUMPER_SERVER)%

启动 VarDumper 服务器

./bin/console server:dump --format html > ./public/debug.html

在浏览器中打开: http://local-shopware:8000/debug.html

启动 SQL 记录器

\StartSQLLog(useVarDumper: true);

屏幕截图

CLI

Example CLI