2017 © Pedro Peláez
 

library dump

D::ump - a PHP 5.4 print_r/var_dump replacement base on Krumo

image

aronduby/dump

D::ump - a PHP 5.4 print_r/var_dump replacement base on Krumo

  • Friday, September 30, 2016
  • by aronduby
  • Repository
  • 1 Watchers
  • 4 Stars
  • 2,801 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 3 Versions
  • 23 % Grown

The README.md

D::ump

A print_r/var_dump replacement for PHP >= 5.4.0 based on Krumo and the oodle/krumo fork., (*1)

D::ump screenshot, (*2)

Differences from Krumo

  • modified HTML, CSS, and JS has been completely reworked, makes multiple arguments passed look like they're together
  • added Passing in bitmask to be able to do Titles, Output Buffering, and Stopping Executing after output
  • added Object Reflection to not only show the properties (which are now sorted as arrays) but also:
    • Parent Class Name
    • Interface Names
    • Trait Names
    • Constants
    • Methods (with the argument list and defaults*)
  • added Callables are now first class citizens instead of strings, complete with argument list and defaults* from reflection
  • removed All the different skins, if you really want it to look different there's a css_file config option, but who cares, its development
  • removed All the helper functions, because why not just type D::ump($_ENV), not like your going to remember them all anyway
  • removed .ini settings file is gone, use D::config() if you want to set global changes
  • probably some other things...

Note: reflection can't get the default values for arguments of built-in methods/functions, it will display the argument name with a note in these circumstances, (*3)

Install

Using Composer

{
    "require": {
        "aronduby/dump" : "*"
    }
}

then run composer install or composer update, (*4)

Usage

Basic Usage

D::ump($arg1);

You can also pass multiple arguments:, (*5)

D::ump($arg1, $arg2, $arg3);

Dump Settings

If you pass an instance of D\DumpSettings as the last argument to D::ump you can set a title, output buffer the return, kill the process after returning, and expand all the collapsibles by default., (*6)

$ds = new \D\DumpSettings(D::KILL | D::EXPAND, 'This is a Title');
D::ump($arg1, $arg2, $ds);

Short Cut:

The D object has a shortcut to quickly create and return an instance of D\DumpSettings, so the same example could be rewritten as, (*7)

D::ump($arg1, $arg2, D::S(D::KILL | D::EXPAND, 'This is a Title'));

Flags

The following flags are available as constants of the D class: - D::KILL -- will call die() after output - D::OB -- will use the output buffer and return the output instead of printing it - D::EXPAND -- starts with the output fully expanded - D::IGNORE_CLI -- by default, if the script detects you are running command line it just uses print_r, use this to include the full output, useful if you are doing html logging, (*8)

Note: Passing a bitmask containing both D::KILL and D::OB will result in an InvalidArgumentException being thrown since you can't do both Note: D\DumpSettings also has a backtrace property which is used by D::ump(), (*9)

Config

You can globally modify the following properties by passing an associative array into D::config($arr) with the following values, (*10)

Key Type Default Description
enabled Boolean true globally enabled/disable output, can also call D::disable & D::enable
css_file String null path to a custom CSS file, file will be read in using file_get_contents, should be absolute path
display.separator String => string to use as a separator between the key/values (the default is wrapped in spaces)
display.truncate_length Integer 80 If a string is longer than X characters it will be truncated with the non-truncated version displaying as a collapsible
display.cascade Array null Array of integers to determine when a level should collapse. If the specified level has greater than X amount of element it shows collapsed. display.cascade=>[5,10] will expand the first level if there are 5 or less items and the second level with 10 or less. Set to null to have everything collapse
display.show_version Boolean true Include version # and link in the footer of the output
display.show_call_info Boolean true Include the file/line # D was called from
display.replace_returns Boolean false Should we replace returns \n with br's in the output
sorting.arrays Boolean true Reorder associative arrays (and object properties and methods) based on their keys

Example

D::config([
    'css_file' => "absolute/path/to/your/custom/css/file.css",
    'display.cascade' => [5, 10],
    'sorting.arrays' => false
]);
// ... some other stuff in your code
D::ump($arg1);

The Versions

30/09 2016

dev-master

9999999-dev

D::ump - a PHP 5.4 print_r/var_dump replacement base on Krumo

  Sources   Download

The Requires

  • php >=5.3

 

by Aron Duby

debug dump debugging print print_r var_dump pretty krumo

30/09 2016

0.9.1

0.9.1.0

D::ump - a PHP 5.4 print_r/var_dump replacement base on Krumo

  Sources   Download

The Requires

  • php >=5.3

 

by Aron Duby

debug dump debugging print print_r var_dump pretty krumo

04/04 2014

v0.9

0.9.0.0

D::ump - a PHP 5.4 print_r/var_dump replacement base on Krumo

  Sources   Download

The Requires

  • php >=5.3

 

by Aron Duby

debug dump debugging print print_r var_dump pretty krumo