2017 © Pedro Peláez
 

library pre

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

image

paste/pre

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

  • Wednesday, June 12, 2013
  • by paste
  • Repository
  • 1 Watchers
  • 16 Stars
  • 1,814 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Pre

A handsome replacement for print_r & var_dump. Output debugging info in a minimally styled <pre> block., (*1)

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

Basic Example, (*2)

// 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, (*3)

Installation

Use Composer. Add paste/pre to your project's composer.json:, (*4)

{
    "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:, (*5)

<?php
// 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., (*6)

Optional: - add a label to identify the data - configure the height/width of the <pre> block, (*7)

Direct Output

<?php
// 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

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

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

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

vs. print_r() and var_dump()

Comparison, (*8)

The Versions

12/06 2013

dev-master

9999999-dev https://github.com/paste/Pre.php

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

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

debug dump print print_r var_dump pretty pre