PHP Classes

PHP var_dump Pretty Class: Colored output values of variables to look pretty

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-06-03 (6 hours ago) RSS 2.0 feedNot yet rated by the usersTotal: 111 All time: 9,641 This week: 488Up
Version License PHP version Categories
dump7 1.0.1BSD License7HTML, Language, PHP 7
Description 

Author

This class can generated colored output values of variables to look pretty.

It can take the values of one or more variables and generates HTML output that presents the values of the variables in a nice way using colors to represent each data types value.

The class allows configuring the colors that are used to display each type of value.

Picture of chrys ugwu
  Performance   Level  
Name: chrys ugwu <contact>
Classes: 16 packages by
Country: Nigeria Nigeria
Innovation award
Innovation award
Nominee: 4x

Documentation

Pretty Data Dump

A pretty version of php var_dump. This class displays structured information about one or more expressions that includes its type and value.

_Check out Dump5 for PHP 5+_

Installation

You can download the Latest release version as a standalone, alternatively you can use Composer

composer require ghostff/dump7
"require": {
    "ghostff/dump7": "^1.0"
}

Display Flags

You can simple hide or show some object attribute using a Doc block flag:

| | | |-------------------------------|---------------------------------------------------| | @dumpignore-inheritance | Hides inherited class properties. | | @dumpignore-inherited-class | Hides the class name from inherited properties. | | @dumpignore-private | Show all properties except the private ones. | | @dumpignore-protected | Show all properties except the protected ones.| | @dumpignore-public | Show all properties except the public ones. | | @dumpignore | Hide the property the Doc comment belongs to. |

/
* @dumpignore-inheritance
* @dumpignore-inherited-class
* @dumpignore-private
* @dumpignore-public
* @dumpignore-public
*/
Class Foo extends Bar {
    / @dumpignore */
    private ?BigObject $foo = null;
}

Usage

class FooBar
{
    private $inherited_int   = 123;
    private $inherited_array = ['string'];
}

class Bar extends FooBar
{
    private $inherited_float = 0.22;
    private $inherited_bool  = 1 == '1';
}

class Foo extends Bar
{
    private $string = 'string';
    protected $int  = 10;
    public $array   = [
        'foo' => 'bar'
    ];
    protected static $bool = false;
}

$string   = 'Foobar';
$array    = ['foo', 'bar'];
$int      = 327626;
$double   = 22.223;
$null     = null;
$bool     = true;
$resource = fopen('LICENSE', 'r');
$m        = microtime(true);

new Dump(new Foo, $string, $array, $int, $double, $null, $bool, [
    'foo' => 'bar',
    'bar' => 'foo',
    [
        'foo' => 'foobar',
        'bar_foo',
        2 => 'foo',
        'foo' => [
            'barbar' => 55,
            'foofoo' => false,
            'foobar' => null,
        ]
    ]
], $resource);

new Dump(1 == '1', 1 === '1');
Dump::safe(...$args); # running on terminal without color capabilities.

Replacing predefined colors:

# set($name, [$cgi_color, $cli_color]);
Dump::set('boolean', ['bb02ff', 'purple']);

By default, when Dump is called inside a function, the call line is set to new Dump inside the function instead of the function call. With setTraceOffset you can set the offset of each call line.

function dump()
{
    Dump::setTraceOffset(2);
    new Dump(...func_get_args()); # Dont use this test.php(line:4) as call line
}

dump('foo', 22, 'bar', true); // Use test.php(line:7) instead

CGI output:

cgi screenshot

CLI(Unix):


cli screenshot

CLI(Window):

cli screenshot


  Files folder image Files (8)  
File Role Description
Files folder imagesrc (1 file)
Image file cgi.png Data Auxiliary data
Plain text file composer.json Data Auxiliary data
Plain text file index.php Class Class source
Plain text file LICENSE Lic. License text
Image file posix.png Data Auxiliary data
Image file posixWin.png Data Auxiliary data
Plain text file README.md Doc. Documentation

  Files folder image Files (8)  /  src  
File Role Description
  Plain text file Dump.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:111
This week:0
All time:9,641
This week:488Up