PHP Classes

PHP var_dump Pretty: Display the values of variables in readable format

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 232 All time: 8,131 This week: 39Up
Version License PHP version Categories
kayalion 1.0.0MIT/X Consortium ...5PHP 5, Tools, Data types


This package can display the values of variables in readable format.

It can take a variable and outputs its value in a way that is easy to read.

The package can output the variable value either to a browser in HTML, to a command line console in plain text, or to a file.

Picture of Joris Vandeweerd
Name: Joris Vandeweerd <contact>
Classes: 1 package by
Country: Belgium Belgium
Age: ???
All time rank: 405024 in Belgium Belgium
Week rank: 246 Up2 in Belgium Belgium Up



PHP Helper library to print variables for debugging purposes.



// dumps a variable
vd("any variable");

// or multiple variables, as many as your memory can handle
vd("any variable", "any other variable");

// dumps a variable and dies
vdd("any variable");

// or with multiple variables
vdd("any variable", "any other variable");

// dumps one variable with a specific configuration
// set any configuration parameter to null to use the global value
$maxRecursiveDepth = 10;
$maxStringLength = 100;
$includeMethods = true;
$theme = new SpidermanHtmlVarDumpTheme();

vdc("any variable", $maxRecursiveDepth, $maxStringLength, $includeMethods, $theme);

// dumps one variable with a specific configuration and dies
vdcd("any variable", $maxRecursiveDepth, $maxStringLength, $includeMethods, $theme);

// as called for the sample screenshots
    "any string",
    new Exception(),
    fopen('php://stdout', 'w'),


Output on a HTML page:

Screenshot HTML

Output in a CLI:

Screenshot CLI


You can use the environment variable to configure the vardump.


// Flag to see if object methods should be included

// Maximum depth for arrays and objects

// Maximum length for the preview of a string

// Name of the CLI theme class
$_ENV['VAR_DUMP_THEME_CLI'] = 'CliVarDumpTheme';

// Name of the HTML theme class, choose between:
// - HtmlVarDumpTheme
// - BatmanHtmlVarDumpTheme
// - HulkHtmlVarDumpTheme,
// - IronmanHtmlVarDumpTheme,
// - SpidermanHtmlVarDumpTheme,
// - SupermanHtmlVarDumpTheme,
$_ENV['VAR_DUMP_THEME_HTML'] = 'SpidermanHtmlVarDumpTheme';

Dump To File

When you are debugging a web application, output can break your layout or response, especially when developing a restful API.

You can easily pipe the vardump output to a file using the file theme.


// the file to dump to
$file = __DIR__ . '/vardump.log';

// create a theme to log to the file
$theme = new FileVarDumpTheme($file);

// you can also provide a truncate size in KB, defaults to 1MB
$theme = new FileVarDumpTheme($file, 4096); // 4MB

// set the theme for both environments
$_ENV['VAR_DUMP_THEME_CLI'] = $theme;
$_ENV['VAR_DUMP_THEME_HTML'] = $theme;

Once the log file is created, you can use the `tail` command to keep an eye on it:

tail -f vardump.log


You can use Composer to install this helper into your project.

composer require kayalion/vardump

For manual installation, copy the `src/VarDump.php` file to your project and include it like:


include __DIR__ . '/src/VarDump.php';

  • screenshot-cli.png
  • screenshot-html.png
  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Accessible without login Plain text file Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file Example Example script

  Files folder image Files  /  src  
File Role Description
  Plain text file VarDump.php Class Class source

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:8,131
This week:39Up