A handsome replacement for print_r & var_dump. Debugging output with understated style.

dev-master 2013-06-12 03:56 UTC


A handsome replacement for print_r & var_dump. Output debugging info in a minimally styled <pre> block.

// basic usage
echo Pre::r($data);

Basic Example

// add data to storage queue with label
Pre::add($data, 'My Debug Data');

// configure dimensions
Pre::$config['width'] = 400;
Pre::$config['height'] = 80;

// render and clear queue
echo Pre::render();

Label Example


Use Composer. Add paste/pre to your project's composer.json:

    "require": {
        "paste/pre": "dev-master"

Or just include Pre.php directly into your project. You might also want to setup the Pre() function shortcut for convenience:

// include Pre lib
require '/path/to/src/Paste/Pre.php';

// setup Pre() function shortcut
if (! function_exists('Pre')) {
	function Pre($data, $label = NULL) {
		return Paste\Pre::render($data, $label);

Basic Usage

You can use Pre in two basic ways; output debugging data directly to the browser or add the data to a queue and display it later in execution.


  • add a label to identify the data
  • configure the height/width of the <pre> block

Direct Output

// using function shorcut
echo Pre($data);

// using shortcut r() method with label
echo Pre::r($data, 'Debug Label');

// using regular render() method, no label
echo Pre::render($data);

Data Queue

// add data to queue with a label
Pre::add($data1, 'Debug Data #1');

// some stuff...
Pre::add($data2, 'Debug Data #2');

// later... display the data
echo Pre::render();

vs. print_r() and var_dump()