定制 webxid/debug-helpers 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

webxid/debug-helpers

Composer 安装命令:

composer require webxid/debug-helpers

包简介

README 文档

README

The lib contains the tools for debug. It doesn't have any external dependencies to other libs or frameworks, so it could be used in any project.

It's helpful for me. Hope, it'll be helpful for someone else

Install

Run composer require webxid/debug-helpers

How To Use

Simple data dump

use function WebXID\DebugHelpers\_dump;
use function WebXID\DebugHelpers\__dump;

_dump($data); // To print data dump into a browser
__dump($data); // To print data dump into a command line

Dump a Backtrace

use function WebXID\DebugHelpers\_backtrace;

_backtrace(); // print a Back trace from a script start file to the currecn place

Get Execution time

use function WebXID\DebugHelpers\_trackTime;

_trackTime('track_magic_time'); // start track of `track_magic_time`

// Do a magic

echo _trackTime('track_magic_time'); // print a `track_magic_time` execution time

echo _trackTime(true); // print the all registered time track keys data

Cache a var data

use function WebXID\DebugHelpers\_cachedLog;

$var = 1;
_cachedLog('$var', $var);

$var = 2;
_cachedLog('$var', $var);

$var = 3;
_cachedLog('$var', $var);

// print cached data of the key `$var` 
print_r(_cachedLog('$var'));
/**
 * will prints the array
 * [
 *      '$var' => [
 *          1,
 *          2,
 *          3,
 *      ],
 * ]
 */
 
 print_r(_cachedLog()); // prints all cached data

Dump data into log file

To dump a data into a log file use the next functions

use WebXID\DebugHelpers\Environment;
use function WebXID\DebugHelpers\_log;
use function WebXID\DebugHelpers\_logWithClean; 
use function WebXID\DebugHelpers\_logAndDie;
use function WebXID\DebugHelpers\_logWithCleanAndDie;

Environment::setRootDir(__DIR__);

_log($data); // Adds Dump of the $data var to the end of log file and continue a script procssing
_logWithClean($data); // Cleaned up the log file, Dumps the $data var and continue a script procssing
_logAndDie($data); // Adds Dump of the $data var to the end of log file and break a script processing
_logWithCleanAndDie($data); // Cleaned up the log file, Adds Dump of the $data var to the end of log file and break a script processing

The log file route: Environment::getRootDir() . '/logs/webxid.log'.

!!! Note !!!

The dir logs has to be readable and writable for the script. Otherwise you will get a permission error.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-04-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固