PHPackages                             bonemeijer/smartdump - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. bonemeijer/smartdump

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

bonemeijer/smartdump
====================

A smarter alternative to var\_dump for PHP8.3+

v0.3.1(7mo ago)217.8k↓19%[1 issues](https://github.com/Bonemeijer/SmartDump/issues)MITPHPPHP &gt;=8.3.0

Since Oct 27Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/Bonemeijer/SmartDump)[ Packagist](https://packagist.org/packages/bonemeijer/smartdump)[ Docs](https://github.com/Bonemeijer/SmartDump)[ RSS](/packages/bonemeijer-smartdump/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (2)Versions (12)Used By (0)

SmartDump
=========

[](#smartdump)

A smarter alternative to var\_dump for PHP8.3+

The goal is to provide a friendly debug tool that is framework independent and works across multiple environments.

[![Build Status](https://camo.githubusercontent.com/9aa1eef70fd8c26885ae27fb7622357f59d702bbdc04df6edd45fb02aaef216c/68747470733a2f2f7472617669732d63692e6f72672f426f6e656d65696a65722f536d61727444756d702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Bonemeijer/SmartDump)[![Latest Stable Version](https://camo.githubusercontent.com/b74c3f7fad2271881588305fe07b715992c1654e9339363962d3f16315e9ca0a/68747470733a2f2f706f7365722e707567782e6f72672f626f6e656d65696a65722f736d61727464756d702f762f737461626c65)](https://packagist.org/packages/bonemeijer/smartdump)[![Total Downloads](https://camo.githubusercontent.com/82037b2ed53a88c7d690ac0c75c6bac095c7d8a5a8da4b6e36eb20496b276655/68747470733a2f2f706f7365722e707567782e6f72672f626f6e656d65696a65722f736d61727464756d702f646f776e6c6f616473)](https://packagist.org/packages/bonemeijer/smartdump)[![License](https://camo.githubusercontent.com/778a8bde1e7bfbd2bf60d078a4e8fbea8a157abdfaa511a1c44f28bce931e69b/68747470733a2f2f706f7365722e707567782e6f72672f626f6e656d65696a65722f736d61727464756d702f6c6963656e7365)](https://packagist.org/packages/bonemeijer/smartdump)

### Installing

[](#installing)

This project is still in beta. Backwards incompatible changes might be introduced during this time.

```
composer require --dev bonemeijer/smartdump

```

Basic usage
-----------

[](#basic-usage)

By default, SmartDump is configured to detect where you are debugging from and will output either plaintext or html. For example: when you dump from the commandline, a plaintext output is used. But when you are debugging from a browser, an interactive HTML output is used.

There is a main `SmartDump` class, which provides a friendly global interface to debug a variable anywhere in your code. But don't worry, you can use and configure your own instances too.

```
\SmartDump\SmartDump::dump($variable);
```

### Shortcut functions

[](#shortcut-functions)

Even easier are the shortcut functions. These live in the global namespace so you don't have to do any imports when you quickly want to debug a variable.

Available functions:

- `smartdump($variable)` - shortcut for `\SmartDump\SmartDump::dump($variable);`
- `smartdump_text($variable)` - dump plaintext to output
- `smartdump_html($variable)` - dump simplehtml to output
- `smartdump_text_stream` - dump plaintext to a file or url
- `d($variabe)` - dump a context aware format to output
- `o($variabe)` - dump a context aware format to output, clear output buffer and exit()

**TIP** - the shortcut function `smartdump()` uses the global SmartDump class, so you can configure the desired behaviour through the SmartDump class.

Advanced usage
--------------

[](#advanced-usage)

SmartDump will internally convert any passed variable to a *Node* using a *NodeFactory*. These Nodes will then be passed to a *Dumper*, which will accept *Formatter* to render an output format.

### Nodes

[](#nodes)

A *Node* is basically an internal representation of a variable. The `DefaultNodeFactory` has support for all regular PHP variable types like booleans, strings, integers, floats, arrays, objects, resources and NULL values.

### Formatters

[](#formatters)

A formatter formats the *Node* to output that can be handles by a *Dumper*. At this time there are only string type formatters, which will render a *Node* to a string.

By default, the `ContextAwareStringFormatter` will be used, which will return a formatter based on where you are debugging from.

Available formatters:

- `PlainTextStringFormatter` - formats to plaintext, for use in commandline and other text based environments
- `DomStringFormatter` - can use a `Markup` document to output HTML (or someday XML or any other markup language)
- `ContextAwareStringFormatter` - switches between plaintext and dom based on the current environment
- `CallBackStringFormatter` - accepts callbacks to determine which formatter is used

To globally use a different formatter for all `SmartDump::dump()` calls:

```
\SmartDump\SmartDump::setFormatter(
    new \SmartDump\Formatter\StringFormatter\PlainTextStringFormatter()
);
```

### Dumpers

[](#dumpers)

A *Dumper* will determine how the formatted node will be handled. By default, the `OutputDumper` is used, which will just echo the output to the screen.

Available dumpers:

- `OutputDumper` - simply echo's the output
- `StreamDumper` - dumps the formatted output to a file or stream

To globally use a different dumper for all `SmartDump::dump()` calls:

```
\SmartDump\SmartDump::setDumper(
    new \SmartDump\Dumper\StreamDumper('output.txt')
);
```

Deployment
----------

[](#deployment)

Don't. Don't deploy debug tools. Which is why I recommend using the `--dev` flag during installation.

Versioning
----------

[](#versioning)

SmartDump uses [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/Bonemeijer/SmartDump/tags).

Authors
-------

[](#authors)

- **Maurice Bonemeijer** - *Initial work* - [Bonemeijer](https://github.com/Bonemeijer)

See also the list of [contributors](https://github.com/Bonemeijer/SmartDump/contributors) who participated in this project.

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

Links
-----

[](#links)

- [Travis-CI build on travis-ci.org](https://travis-ci.org/Bonemeijer/SmartDump)
- [SonarQube report on sonarcloud.io](https://sonarcloud.io/dashboard?id=bonemeijer%3Asmartdump)

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance55

Moderate activity, may be stable

Popularity28

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 98.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~291 days

Recently: every ~447 days

Total

11

Last Release

213d ago

PHP version history (2 changes)v0.1PHP &gt;=5.6.0

v0.3.0PHP &gt;=8.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/230fc27832a74a1c8db5dd6f736f0ea7c5d8ec500b374036b60352bc4b273361?d=identicon)[Bonemeijer](/maintainers/Bonemeijer)

---

Top Contributors

[![Bonemeijer](https://avatars.githubusercontent.com/u/7499085?v=4)](https://github.com/Bonemeijer "Bonemeijer (66 commits)")[![mbonemeijer-visymo](https://avatars.githubusercontent.com/u/37288561?v=4)](https://github.com/mbonemeijer-visymo "mbonemeijer-visymo (1 commits)")

---

Tags

debugvar\_dump

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bonemeijer-smartdump/health.svg)

```
[![Health](https://phpackages.com/badges/bonemeijer-smartdump/health.svg)](https://phpackages.com/packages/bonemeijer-smartdump)
```

###  Alternatives

[digitalnature/php-ref

A nicer print\_r/var\_dump alternative for PHP 5.3+

351696.0k13](/packages/digitalnature-php-ref)[koriym/printo

An object graph visualizer.

1421.8M2](/packages/koriym-printo)[mmucklo/krumo

KRUMO - version 2.0 of print\_r(); and var\_dump(); (with new updates)

89168.0k6](/packages/mmucklo-krumo)[leeoniya/dump-r

a cleaner, leaner mix of print\_r() and var\_dump()

12368.1k5](/packages/leeoniya-dump-r)[jbzoo/jbdump

Script for debug and dump PHP variables and other stuff. This tool is a nice replacement for print\_r() and var\_dump() functions.

211.1M3](/packages/jbzoo-jbdump)[kktsvetkov/krumo

Krumo is a debugging tool, which displays structured information about any PHP variable. It is a nice replacement for print\_r() or var\_dump() which are used by a lot of PHP developers.

8260.7k](/packages/kktsvetkov-krumo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
