flightphp/tracy-extensions

为 Tracy 调试器提供的几个 Flight 专用扩展,帮助您快速调试代码。

v0.2.3 2024-03-12 05:14 UTC

This package is auto-updated.

Last update: 2024-09-12 06:21:20 UTC


README

这是一套扩展,使与 Flight 的协作更加丰富。

  • Flight - 分析所有 Flight 变量。
  • 数据库 - 分析页面运行的所有查询(如果您正确初始化了数据库连接)
  • 请求 - 分析所有 $_SERVER 变量,并检查所有全局负载($_GET$_POST$_FILES
  • 会话 - 如果有活动会话,分析所有 $_SESSION 变量。

这是面板

Flight Bar

每个面板都会显示关于您的应用程序的非常有用的信息!

Flight Data Flight Database Flight Request

安装

运行 composer require flightphp/tracy-extensions --dev 并开始使用!

配置

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

<?php

use Tracy\Debugger;
use flight\debug\tracy\TracyExtensionLoader;

// bootstrap code
require __DIR__ . '/vendor/autoload.php';

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

// if you use database connections in your app, there is a 
// required PDO wrapper to use ONLY IN DEVELOPMENT (not production please!)
// It has the same parameters as a regular PDO connection
$pdo = new PdoQueryCapture('sqlite:test.db', 'user', 'pass');
// or if you attach this to the Flight framework
Flight::register('db', PdoQueryCapture::class, ['sqlite:test.db', 'user', 'pass']);
// now whenever you make a query it will capture the time, query, and parameters

// This connects the dots
if(Debugger::$showBar === true) {
	new TracyExtensionLoader(Flight::app());
}

// more code

Flight::start();