Skip to content

A PHP helper class to nicely print out variables, including the name of the variable itself (or even an expression). Nicely outputs to browser and CLI, including pipes.

License

Notifications You must be signed in to change notification settings

MrLunar/php-dbg-dumper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DBG Dumper

A prettified PHP variable dumper. Outputs nicely to the browser and CLI (included piped output). Does not replace var_export or print_r, but merely acts a wrapper to these core PHP functions.

About

For each argument provided, it spits out the file name, line number, variable type, variable name and value. The output always displays nicely even if through a browser, a terminal or even piped into less or into a file.

The unique selling point here is the output of the variable name or the given expression. This gives quick visibility of many variables at once (rather than trying to remember which order you dumped your vars).

Install

Create a composer.json file for your project, and include the following:

{
    "require": {
        "mrlunar/php-dbg-dumper": "dev-master"
    }
}

Examples

The following code:

$my_var = array('my array var');
dbg::print_r($my_var);

would output in the browser like so:

yet would output in the terminal like so:

Also for example, the expression:

dbg::print_r(rand(1, 50));

would output to the browser:

Other Commands

dbg::var_export($my_var);

Same as dbg::print_r($my_var); but using PHP's var_export() output.

dbg::quit();

A verbose exit() so you don't lose yourself in a whitescreen.

dbg::error('a terrible error has occured, run for the hills');
dbg::warning('just an FYI because this will probably cause problems later');
dbg::info('I just want to talk');

Should you feel these are useful in your scripts:

dbg::dump($my_var);

Experimental. Like dbg::print_r() but outputs arrays and objects into a tabular format.

About

A PHP helper class to nicely print out variables, including the name of the variable itself (or even an expression). Nicely outputs to browser and CLI, including pipes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages