n0nag0n/fatfree-tracy-extensions

为 Tracy Debugger 提供的几个针对 Fat-Free 的特定扩展,帮助您快速调试代码。

v0.3.0 2023-09-06 15:06 UTC

This package is auto-updated.

Last update: 2024-09-06 17:30:11 UTC


README

这是一个扩展集合,可以使使用 Fat-Free 的体验更加丰富。

  • F3 - 分析所有 hive 变量。
  • 数据库 - 分析页面运行的所有查询
  • 请求 - 分析所有 $_SERVER 变量并检查所有全局负载($_GET$_POST$_FILES
  • 会话 - 分析所有 $_SESSION 变量

安装

运行 composer require n0nag0n/fatfree-tracy-extensions --dev 并开始吧!

配置

要启动此功能,您需要进行的配置非常少。在使用此功能之前,您需要初始化 Tracy 调试器(请参阅https://tracy.nette.org/en/guide

<?php

use Tracy\Debugger;
use n0nag0n\Tracy_Extension_Loader;

// bootstrap code
$f3 = Base::instance();

Debugger::enable();
// You may need to specify your environment with Debugger::enable(Debugger::DEVELOPMENT)

// Database query profiler (not required)
// Create DB connection
// Variant 1
$f3->set('DB', new DB\SQL('mysql:host=localhost;port=3306;dbname=database', 'username', 'password'));
// OR variant 2
$f3->set('AnyVariableName', new DB\SQL('mysql:host=localhost;port=3306;dbname=database', 'username', 'password'));
// OR variant 3
$my_db_connection = new DB\SQL('mysql:host=localhost;port=3306;dbname=database', 'username', 'password');

$extension_options = [
	// Variant 2: Specify the name of the variable F3 with database connection
	'database_variable_name' => 'AnyVariableName', //It will mean: $f3->get('AnyVariableName')
	// OR variant 3: pass the database connection object
	'database_object' => $my_db_connection
];
new Tracy_Extension_Loader($f3, $extension_options);

// If you have no database connection or your connection is written in $f3->set('DB') (variant 1),
// you don't need to create $extension_options because the name 'DB' is used by default, simple:
// new Tracy_Extension_Loader($f3);

// more code

$f3->run();