This package is abandoned and no longer maintained. No replacement package was suggested.

NumberTwo is a classy variable dumper

1.0.0 2013-07-25 07:47 UTC

This package is auto-updated.

Last update: 2020-01-19 10:35:00 UTC


NumberTwo is a classy variable dumper.

Build Status

When var_dump or print_r is too verbose or unpleasant to read, go for NumberTwo.


echo NumberTwo::dump(null);
// null

echo NumberTwo::dump(true);
// true
echo NumberTwo::dump(false);
// false

echo NumberTwo::dump(1);
// 1

echo NumberTwo::dump('foo');
// "foo"


echo NumberTwo::dump(array('foo', 'bar'));
    0 => "foo"
    1 => "bar"
echo NumberTwo::dump(array('foo' => 'bar'));
    "foo" => "bar"


echo NumberTwo::dump($object);
My\ClassWithPublicProperties {
    foo: "aaa"
    bar: "bbb"

You can configure the recursive depth:

echo NumberTwo::dump($otherObject, 2);
UnitTest\NumberTwo\PublicProperties {
    foo: UnitTest\NumberTwo\PublicProperties {
        foo: UnitTest\NumberTwo\PrivateProperties { ... }
        bar: null
    bar: null


You may want to pre-process some objects that are to be dumped.

For that, you can use the filters:

$filters = array(new MyFilter());

echo NumberTwo::dump($otherObject, 2, $filters);

Doctrine Collection

NumberTwo provides a filter for Doctrine's collections:

use NumberTwo\Filter\DoctrineCollectionFilter;

$filters = array(new DoctrineCollectionFilter());

echo NumberTwo::dump($otherObject, 2, $filters);

This filter will turn any Collection (ArrayCollection, PersistentCollection, …) into a PHP array (using the toArray() method).

Doctrine proxies

NumberTwo provides a filter for Doctrine's proxies:

use NumberTwo\Filter\DoctrineProxyFilter;

$filters = array(new DoctrineProxyFilter());

echo NumberTwo::dump($otherObject, 2, $filters);

This filter will load uninitialized proxies and clean up properties.

Feel free to submit other filters in a pull request.


NumberTwo is under the MIT license.