martinlindhe/php-debughelper

0.1.17 2015-08-03 12:26 UTC

This package is auto-updated.

Last update: 2024-10-23 03:50:09 UTC


README

Build Status https://packagist.org/packages/martinlindhe/php-debughelper

Installation

With Composer

composer require martinlindhe/php-debughelper

or add manually to composer.json:

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

HexPrinter

use DebugHelper\HexPrinter;

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

will output something like

000000: f0 ff 00                                         ...

BinaryPrinter

use DebugHelper\BinaryPrinter;

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

will output something like

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";

Logging

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

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

Helpers

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