baraja / breakpoint-debugger
本包最新版本(v1.1.1)没有提供许可证信息。
类似XDebug的运行时逐步代码调试器,但为原生PHP。
v1.1.1
2018-05-28 07:20 UTC
This package is not auto-updated.
Last update: 2024-09-18 03:58:12 UTC
README
原生PHP运行时逐步代码调试器
此工具提供在应用程序执行时调试PHP应用程序的可能性。
调试器类似于另一个现有工具:XDebug。然而,我们与其他工具的主要优势是它快速安装,无需额外依赖,即使在生产或CLI模式下也易于使用。
安装
以下说明将指导您完成安装过程。
1) 使用Composer将依赖项安装到您的程序中。
composer require baraja/breakpoint-debugger
2) 在index.php中初始化调试器
<?php
// Path to Debugger class
require __DIR__ . '/../vendor/baraja/breakpoint-debugger/src/Debugger.php';
// Path to a temporary directory
\Baraja\BreakpointDebugger\Debugger::init(__DIR__ . '/../temp');
// Optional: will extend the execution limit to 5 minutes
// set_time_limit(300);
注意:调试器必须在Composer自动加载之前加载,以便跟踪应用程序的每个部分。
用法
要使用调试器,只需将参数?debugWindow
添加到您的脚本的URL中。示例URL:http://localhost/project/index.php?debugWindow
。
如果您想在应用程序中添加断点,请添加函数调用debug_breakpoint(string $debug_message)
。
示例
function factorial(int $number) {
if ($number < 2) {
debug_breakpoint('Return 1, stop algorithm');
return 1;
} else {
return ($number * factorial($number - 1));
}
}
在调试模式下启动您的应用程序后,将出现一个包含调试信息的附加窗口。窗口将自动更新。
每次PHP执行debug_breakpoint
函数时,脚本将暂停,直到用户决定下一步操作。