martinlindhe/php-debughelper

0.1.17 2015-08-03 12:26 UTC

This package is auto-updated.

Last update: 2024-09-23 03:38:16 UTC


README

构建状态 https://packagist.org.cn/packages/martinlindhe/php-debughelper

安装

使用 Composer

composer require martinlindhe/php-debughelper

或手动添加到 composer.json

{
    "require": {
        "martinlindhe/php-debughelper": "~0.1"
    }
}

HexPrinter

use DebugHelper\HexPrinter;

echo HexPrinter::render("\xF0\xFF\x00");

将输出类似

000000: f0 ff 00                                         ...

BinaryPrinter

use DebugHelper\BinaryPrinter;

echo BinaryPrinter::render("\xF0\xFF\x00");

将输出类似

000000: 11110000 11111111 00000000                 ...

Stopwatch

use DebugHelper\Stopwatch;

$watch = new Stopwatch;
$watch->start();
// do some heavy lifting ...
$watch->stop();

echo $watch->getElapsedTime()." seconds elapsed\n";

日志记录

dbg($msg); // write to stdout if DEBUG=1
nfo($msg);
err($msg);

dbgTime($msg);
nfoTime($msg);
errTime($msg);

辅助工具

d()       dumps variable, using symfony/var-dumper
dd()      dump and die
bt($ex = null)  prints a backtrace (optionally from exception)
dh()      shorthand for DebugHelper\HexPrinter::render()
dbits()   shorthand for DebugHelper\BinaryPrinter::render()
dm()      prints current memory usage
apcm()    prints memory usage by the apc extension