tumtum/sw6-sql-logger 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tumtum/sw6-sql-logger

最新稳定版本:1.2.0

Composer 安装命令:

composer require tumtum/sw6-sql-logger

包简介

Returns SQL queries to the Browser or cli.

README 文档

README

Returns all SQL queries into console of a Browser or cli.

Install

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

Usage

Just set the function StartSQLLog() somewhere and from that point on all SQLs will be logged.

\StartSQLLog();

$result = $this->productRepository->search(new Criteria(['product.id']), $context);

\StopSQLLog();

Usage with VarDumper::dump()

If you want to dump the SQLs into the VarDumper::dump() and put out the result into a HTML file, you can use the following step:

Configure the Shopware 6 (one time):
# config/packages/dev/debug.yml
debug:
    dump_destination: tcp://%env(VAR_DUMPER_SERVER)%
Start the VarDumper server:
./bin/console server:dump --format html > ./public/debug.html

open in Browser: http://local-shopware:8000/debug.html

Start the SQL logger:
\StartSQLLog(useVarDumper: true);

Usage with Ray

Ray is a powerful debugging tool for PHP developers.

Call in Ray Style:
ray()->showQueries()

// This query will be displayed.
$this->productRepository->search(new Criteria(['product.id']), $context);

ray()->stopShowingQueries();

// This query won't be displayed.
$this->productRepository->search(new Criteria(['product.id']), $context);

Alternatively, you can pass a callable to showQueries. Only the queries performed inside that callable will be displayed in Ray. If you include a return type in the callable, the return value will also be returned.

// This query won't be displayed.
$this->productRepository->search(new Criteria(['product.id']), $context);

ray()->showQueries(function() {
    // This query will be displayed.
    $this->productRepository->search(new Criteria(['product.id']), $context); 
});

$users = ray()->showQueries(function () {
    // This query will be displayed and the collection will be returned.
    return $this->productRepository->search(new Criteria(['product.id']), $context);
});

$this->productRepository->search(new Criteria(['product.id']), $context); // this query won't be displayed.
Call Classic
#Classic
\StartSQLLog(useRayDumper: true);

To ensure Ray works correctly, you need to install the corresponding package:

composer require --dev spatie/ray

Screenshots

CLI:

Example CLI

统计信息

  • 总下载量: 869
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2023-07-31