Go to file
Jeff Welch eb54a69388 Do not advertise PEAR as an installation method
Sync with sebastianbergmann/phpunit-documentation@05bffa8
2014-05-05 04:31:02 -04:00
src fix SplObjectStorage output in future HHVM releases 2014-02-13 11:12:50 -08:00
tests Workaround for "Nesting level too deep - recursive dependency?" fatal error on PHP 5.3.3 2014-04-18 11:45:21 +02:00
.gitignore Ignore .idea directory 2014-04-18 11:32:10 +02:00
.travis.yml * Remove Travis CI notification hook for IRC 2014-05-04 11:43:29 +02:00
LICENSE Blank line at eof 2014-02-16 11:50:18 +00:00
README.md Do not advertise PEAR as an installation method 2014-05-05 04:31:02 -04:00
build.xml Update composer.phar when it is older than 30 days 2014-04-27 09:18:52 +02:00
composer.json Use stable dependencies 2014-04-18 11:16:18 +02:00
phpunit.xml.dist Cleanup 2014-01-29 18:56:09 +01:00

README.md

Exporter

Build Status

This component provides the functionality to export PHP variables for visualization.

Usage

Exporting:

<?php
use SebastianBergmann\Exporter\Exporter;

/*
Exception Object &0000000078de0f0d000000002003a261 (
    'message' => ''
    'string' => ''
    'code' => 0
    'file' => '/home/sebastianbergmann/test.php'
    'line' => 34
    'trace' => Array &0 ()
    'previous' => null
)
*/

print new Exporter(new Exception);

Data Types

Exporting simple types:

<?php
use SebastianBergmann\Exporter\Exporter;

// 46
print new Exporter(46);

// 4.0
print new Exporter(4.0);

// 'hello, world!'
print new Exporter('hello, world!');

// false
print new Exporter(false);

// NAN
print new Exporter(acos(8));

// -INF
print new Exporter(log(0));

// null
print new Exporter(null);

// resource(13) of type (stream)
print new Exporter(fopen('php://stderr', 'w'));

// Binary String: 0x000102030405
print new Exporter(chr(0) . chr(1) . chr(2) . chr(3) . chr(4) . chr(5));

Exporting complex types:

<?php
use SebastianBergmann\Exporter\Exporter;

/*
Array &0 (
    0 => Array &1 (
        0 => 1
        1 => 2
        2 => 3
    )
    1 => Array &2 (
        0 => ''
        1 => 0
        2 => false
    )
)
*/

print new Exporter(array(array(1,2,3), array("",0,FALSE)));

/*
Array &0 (
    'self' => Array &1 (
        'self' => Array &1
    )
)
*/

$array = array();
$array['self'] = &$array;
print new Exporter($array);

/*
stdClass Object &0000000003a66dcc0000000025e723e2 (
    'self' => stdClass Object &0000000003a66dcc0000000025e723e2
)
*/

$obj = new stdClass();
$obj->self = $obj;
print new Exporter($obj);

Compact exports:

<?php
use SebastianBergmann\Exporter\Exporter;

// Array ()
$exporter = new Exporter(array());
print $exporter->shortenedExport();

// Array (...)
$exporter = new Exporter(array(1,2,3,4,5));
print $exporter->shortenedExport();

// stdClass Object ()
$exporter = new Exporter(new stdClass);
print $exporter->shortenedExport();

// Exception Object (...)
$exporter = new Exporter(new Exception);
print $exporter->shortenedExport();

// this\nis\na\nsuper\nlong\nstring\nt...\nspace
$exporter = new Exporter(
<<<LONG_STRING
this
is
a
super
long
string
that
wraps
a
lot
and
eats
up
a
lot
of
space
LONG_STRING
);
print $exporter->shortenedExport();

Installation

To add Exporter as a local, per-project dependency to your project, simply add a dependency on sebastian/exporter to your project's composer.json file. Here is a minimal example of a composer.json file that just defines a dependency on Exporter 1.0:

{
    "require": {
        "sebastian/exporter": "1.0.*"
    }
}