jambagecom/fh-debug 问题修复 & 功能扩展

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

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

jambagecom/fh-debug

Composer 安装命令:

composer require jambagecom/fh-debug

包简介

FH Debug - PHP debugger, sys_log and devLog Logger

README 文档

README

Installation Requirement

You must overwrite the TYPO3 Core file sysext/core/Resources/PHP/GlobalDebugFunctions.php of a classic installation or the vendor/typo3/cms-core/Resources/PHP/GlobalDebugFunctions.php of a Composer installation by the file fh_debug/Patches/TYPO3/sysext/core/Resources/PHP/GlobalDebugFunctions.php. Alternatively you can use "post-install-cmd" or "post-autoload-dump" and a file copy method in your composer.json. See Defining scripts .

This will bring you back the former methods debugBegin and debugEnd into TYPO3 Core. This also contains the necessary PHP code to call fh_debug if it is activated in the Extension Manager. Only by this file replacement fh_debug will work at all.

What is does

Use this extension to generate debug output files for the PHP code of TYPO3 and TYPO3 extensions in the Front End or Back End if they have PHP debug statements. Consider to also install debug_mysql_db if you want to debug the generated SQL queries or track down the PHP errors in the table sys_log or the Developer traces written to the TYPO3 function devLog.

The debug output is written into a HTML debug output file. All the configuration is done in the Extension Manager for fh_debug. You can design the output by the CSS file fhdebug.css. If you have a lot of debug output then you should put debug (‘B’) and debug (‘E’) PHP commands around the PHP debug commands in order to have fewer debug output lines in the file. These commands will activate and deactivate the debug output.

force output

If a debug (‘B’) is required, but maybe not active, then you can use the third parameter (group) ‘F’ to force an output. This is a special case to produce the output no matter if debug (‘B’) is set to be mandatory or not.

example:

debug ('B');
$a = 'myString';
debug ($a, '$a at position 1');
debug ('E');

No debug output will be shown on the screen. Otherwise you must deactivate the debug output in the Install Tool.

$a = 'myString2';
debug ($a, '$a at position 1', 'F');

The debug output will always be shown.

News

Since version 0.15.0 the global error object is initialized automatically if it is not existent. This allows to insert debug calls almost everywhere in the TYPO3 backend even before the Middleware is dispatched.

Configuration

Just enter any invalid IP address:

[SYS][devIPmask] = 1.1.1.1

The Extension Manager configuration of fh_debug will be added to the IP address of the Install Tool. IPADDRESS = 34.22.11.12. Your current IP address is shown in the Extension Manager view of fh_debug below the field IPADDRESS. If your provides has an ip version 6 activated, then you must enter it in the IPv6 format.

example:

Enter your current IP address 11.12.13.14, if you want to debug this client’s actions.

LocalConfiguration.php:

Use the fh_debug error handler in order to get debug messages of all exceptions. Add these lines into your file LocalConfiguration.php under typo3conf.

'SYS' => array(
   'displayErrors' => '2',
    'errorHandler' => 'JambageCom\\FhDebug\\Hooks\\ErrorHandler',
),

You can show more debug info and a backtrace with the TYPO3 error message Oops, an error occurred!. This is activated by default: OOPS_AN_ERROR_OCCURRED = 1. This will also add a detailed debug output to the debug file.

To get the debug output for “Oops, an error occurred!” you must make this configuration in the Install Tool or LocalConfiguration.php:

[SYS][productionExceptionHandler] =
JambageCom\FhDebug\Hooks\CoreProductionExceptionHandler

Remove this settings before you deinstall fh_debug. Otherwise you will get this PHP error entry:

PHP Fatal error: Uncaught Error: Class ‘JambageCom\FhDebug\Hooks\CoreProductionExceptionHandler’ not found in /var/www/html/typo3_src-9.5.8/typo3/sysext/core/Classes/Utility/GeneralUtility.php:3667

The default setting is:

[SYS][productionExceptionHandler] = TYPO3\CMS\Core\Error\ProductionExceptionHandler

example:

if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('fh_debug')) {
    require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('fh_debug') . 'Classes/Utility/DebugFunctions.php');  // use t3lib_extMgm::extPath in TYPO3 4.5
    // some configuration:
    \JambageCom\Fhdebug\Utility\DebugFunctions::setErrorLogFile(''); // this is necessary if you use the error_log file
    // if you use the debug HTML file:
    \JambageCom\Fhdebug\Utility\DebugFunctions::setDebugFile('fileadmin/debug.html');

    \JambageCom\Fhdebug\Utility\DebugFunctions::setDebugBegin(FALSE);
    \JambageCom\Fhdebug\Utility\DebugFunctions::setRecursiveDepth('12');
    \JambageCom\Fhdebug\Utility\DebugFunctions::setTraceDepth('12');
    \JambageCom\Fhdebug\Utility\DebugFunctions::setAppendDepth('0');
    \JambageCom\Fhdebug\Utility\DebugFunctions::setTypo3Mode('ALL');
    \JambageCom\Fhdebug\Utility\DebugFunctions::setActive(TRUE);
    \JambageCom\Fhdebug\Utility\DebugFunctions::initFile();
}

\JambageCom\Fhdebug\Utility\DebugFunctions::debug ($_EXTCONF, '$_EXTCONF');

If you use the file ext_localconf.php or some of the at first executed TYPO3 core files, then the extension fh_debug has not been initialized yet. Therefore you must use the full namespace class to initialize and to call the class of fh_debug.

Class ‘JambageCom\Fhdebug\Utility\DebugFunctions’ not found in /var/www/html/typo3_src/typo3/sysext/core/Resources/PHP/GlobalDebugFunctions.php line 15

This means that your debug output shall be generated before the extension fh_debug has been initialized by TYPO3. You must do your own initialization by these commands:

example:

require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('fh_debug') . 'Classes/Utility/DebugFunctions.php');
\JambageCom\Fhdebug\Utility\DebugFunctions::init();
\JambageCom\Fhdebug\Utility\DebugFunctions::setErrorLogFile('');
\JambageCom\Fhdebug\Utility\DebugFunctions::setDebugFile('fileadmin/debug.html');

debug ($tmp, 'variable before fh_debug has been started yet.');

debug begin and end

There are 2 control commands available to begin and to end the generation of debug output: debug (‘B’) and debug (‘E’).

debug-begin and debug-end:

example:

debug ('B'); // begin debugging
debug ($myVariable, 'my variable');
debug ('E'); // end debugging

debug object with private members

Use the class \JambageCom\FhDebug\Utility\DebugFunctions::getApi method object2array to convert an object into an array. Then it will be possible to access the formerly private member variables. This is needed for large objects in order to generate less output.

// only for Debug START:
$debugApi = \JambageCom\FhDebug\Utility\DebugFunctions::getApi();
$queryArray = $debugApi->object2array($query);
debug ($queryArray['container'], '$queryArray[\'container\'] search Pos 1');
// only for Debug END:

Error

If fh_debug does not work, then there is probably the case where fh_debug has not been activated yet. You can use PHP error logging as an alternative.

example PHP error_log :

error_log('mymethod Position 2 $variableName: ' .  print_r($variableName, true) . PHP_EOL, 3, '/var/www/html/fileadmin/phpDebugErrorLog.txt');
error_log('printVariable $header: ' . $header . PHP_EOL, 3, \JambageCom\FhDebug\Utility\DebugFunctions::getErrorLogFilename());
error_log('printVariable $variable: ' . substr(json_encode($variable), 0, 120) . PHP_EOL, 3, \JambageCom\FhDebug\Utility\DebugFunctions::getErrorLogFilename());

Use you own path as the last parameter of the above method error_log or use the method getErrorLogFilename to use the error filename set in the extension configuration. Use json_encode to avoid a PHP Fatal error: Allowed memory size of 268435456 bytes exhausted. error.

Trouble shooting

If you do not get anything shown in the browser url https://example.com/fileadmin/debug.html, then make sure that this file debug.html really exists on the file system. If not, then create an empty file debug.html in the folder fileadmin and give Apache write access to it.

Check the configuration in the extension manager. IP addresses of the client browser Put in an asterisk * . Then every client IP address will produce a debug output.

Improvements

Please make an entry directly on the TYPO3 Core bug tracker at add a control function for debugging enhanced debug methods

Global functions can only be implemented in the TYPO3 core.

ToDO

Program a TYPO3 patch extension which overwrites TYPO3 core files. Adapt patch file for TYPO3 14.

jambagecom/fh-debug 适用场景与选型建议

jambagecom/fh-debug 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.09k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 01 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「debug」 「error」 「syslog」 「oops」 「TYPO3 CMS」 「devlog」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 jambagecom/fh-debug 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jambagecom/fh-debug 我们能提供哪些服务?
定制开发 / 二次开发

基于 jambagecom/fh-debug 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2019-01-28