Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sebastianbergmann/exporter
Provides the functionality to export PHP variables for visualization
https://github.com/sebastianbergmann/exporter
Last synced: 14 days ago
JSON representation
Provides the functionality to export PHP variables for visualization
- Host: GitHub
- URL: https://github.com/sebastianbergmann/exporter
- Owner: sebastianbergmann
- License: bsd-3-clause
- Created: 2013-02-04T21:15:26.000Z (almost 12 years ago)
- Default Branch: main
- Last Pushed: 2024-04-04T06:31:40.000Z (7 months ago)
- Last Synced: 2024-05-18T11:04:25.908Z (6 months ago)
- Language: PHP
- Homepage:
- Size: 58.9 MB
- Stars: 6,713
- Watchers: 10
- Forks: 33
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
[![Latest Stable Version](https://poser.pugx.org/sebastian/exporter/v)](https://packagist.org/packages/sebastian/exporter)
[![CI Status](https://github.com/sebastianbergmann/exporter/workflows/CI/badge.svg)](https://github.com/sebastianbergmann/exporter/actions)
[![codecov](https://codecov.io/gh/sebastianbergmann/exporter/branch/main/graph/badge.svg)](https://codecov.io/gh/sebastianbergmann/exporter)# sebastian/exporter
This component provides the functionality to export PHP variables for visualization.
## Installation
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
```
composer require sebastian/exporter
```If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
```
composer require --dev sebastian/exporter
```## Usage
Exporting:
```php
''
'string' => ''
'code' => 0
'file' => '/home/sebastianbergmann/test.php'
'line' => 34
'previous' => null
)
*/print $exporter->export(new Exception);
```## Data Types
Exporting simple types:
```php
export(46);// 4.0
print $exporter->export(4.0);// 'hello, world!'
print $exporter->export('hello, world!');// false
print $exporter->export(false);// NAN
print $exporter->export(acos(8));// -INF
print $exporter->export(log(0));// null
print $exporter->export(null);// resource(13) of type (stream)
print $exporter->export(fopen('php://stderr', 'w'));// Binary String: 0x000102030405
print $exporter->export(chr(0) . chr(1) . chr(2) . chr(3) . chr(4) . chr(5));
```Exporting complex types:
```php
Array &1 (
0 => 1
1 => 2
2 => 3
)
1 => Array &2 (
0 => ''
1 => 0
2 => false
)
)
*/print $exporter->export(array(array(1,2,3), array("",0,FALSE)));
/*
Array &0 (
'self' => Array &1 (
'self' => Array &1
)
)
*/$array = array();
$array['self'] = &$array;
print $exporter->export($array);/*
stdClass Object &0000000003a66dcc0000000025e723e2 (
'self' => stdClass Object &0000000003a66dcc0000000025e723e2
)
*/$obj = new stdClass();
$obj->self = $obj;
print $exporter->export($obj);
```Compact exports:
```php
shortenedExport(array());// Array (...)
print $exporter->shortenedExport(array(1,2,3,4,5));// stdClass Object ()
print $exporter->shortenedExport(new stdClass);// Exception Object (...)
print $exporter->shortenedExport(new Exception);// this\nis\na\nsuper\nlong\nstring\nt...\nspace
print $exporter->shortenedExport(
<<