arashjafari/dump-plus

Provides variety of formats for dumps information about variables or objects

1.0.1 2021-11-20 19:44 UTC

This package is auto-updated.

Last update: 2024-10-21 02:29:15 UTC


README

With DumpPlus, you can view the content of any variable or object in many different formats:

  • syntax highlighting
  • Browsers console log output
  • Via Javascript alert() function
  • Default var_dump() output
  • Command-line interface output
  • Simple format
  • JSON format

Installation

Use Composer to install the library:

$ composer require arashjafari/dump-plus

Screenshots

Screenshot of DumpPlus::pretty($colors); pretty

Screenshot of DumpPlus::console($colors); console

Screenshot of DumpPlus::alert($colors); alert

Example

use ArashJafari\DumpPlus\DumpPlus;

// Sample array to dump
$colors = ['key1' => 'red', 'key2' => 'blue'];

// Default dump output
DumpPlus::dump($colors);

// Dump with syntax highlighting
DumpPlus::pretty($colors);

// Dump in simple format
DumpPlus::simple($colors);

// Dump for CLI output
DumpPlus::cli($colors);

// Dump in browser console
DumpPlus::console($colors);

// Dump in Javascript alert!
DumpPlus::alert($colors);

// Dump in JSON format
DumpPlus::json($colors);

Calling with multiple arguments:

use ArashJafari\DumpPlus\DumpPlus;

$msg = "Hello World!";
$colors = ['key1' => 'red', 'key2' => 'blue'];
 
DumpPlus::dump($msg, $colors);

Calling with functions instead of DumpPlus methods:

$colors = ['key1' => 'red', 'key2' => 'blue'];

dp($colors); // DumpPlus::dump($colors);
dpd($colors); // DumpPlus::dump($colors); die();

dp_pretty($colors); // DumpPlus::pretty($colors);
dpd_pretty($colors); // DumpPlus::pretty($colors); die();

dp_simple($colors); // DumpPlus::simple($colors);
dpd_simple($colors); // DumpPlus::simple($colors); die();

dp_cli($colors); // DumpPlus::cli($colors);
dpd_cli($colors); // DumpPlus::cli($colors); die();

dp_console($colors); // DumpPlus::console($colors);
dpd_console($colors); // DumpPlus::console($colors); die();

dp_alert($colors); // DumpPlus::alert($colors);
dpd_alert($colors); // DumpPlus::alert($colors); die();

dp_json($colors); // DumpPlus::json($colors);
dpd_json($colors); // DumpPlus::json($colors); die();

License

The DumpPlus is open-sourced software licensed under the MIT license.