Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
# sebastian/exporter
2
 
3
[![CI Status](https://github.com/sebastianbergmann/exporter/workflows/CI/badge.svg)](https://github.com/sebastianbergmann/exporter/actions)
4
[![Type Coverage](https://shepherd.dev/github/sebastianbergmann/exporter/coverage.svg)](https://shepherd.dev/github/sebastianbergmann/exporter)
5
 
6
This component provides the functionality to export PHP variables for visualization.
7
 
8
## Installation
9
 
10
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
11
 
12
```
13
composer require sebastian/exporter
14
```
15
 
16
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:
17
 
18
```
19
composer require --dev sebastian/exporter
20
```
21
 
22
## Usage
23
 
24
Exporting:
25
 
26
```php
27
<?php
28
use SebastianBergmann\Exporter\Exporter;
29
 
30
$exporter = new Exporter;
31
 
32
/*
33
Exception Object &0000000078de0f0d000000002003a261 (
34
    'message' => ''
35
    'string' => ''
36
    'code' => 0
37
    'file' => '/home/sebastianbergmann/test.php'
38
    'line' => 34
39
    'previous' => null
40
)
41
*/
42
 
43
print $exporter->export(new Exception);
44
```
45
 
46
## Data Types
47
 
48
Exporting simple types:
49
 
50
```php
51
<?php
52
use SebastianBergmann\Exporter\Exporter;
53
 
54
$exporter = new Exporter;
55
 
56
// 46
57
print $exporter->export(46);
58
 
59
// 4.0
60
print $exporter->export(4.0);
61
 
62
// 'hello, world!'
63
print $exporter->export('hello, world!');
64
 
65
// false
66
print $exporter->export(false);
67
 
68
// NAN
69
print $exporter->export(acos(8));
70
 
71
// -INF
72
print $exporter->export(log(0));
73
 
74
// null
75
print $exporter->export(null);
76
 
77
// resource(13) of type (stream)
78
print $exporter->export(fopen('php://stderr', 'w'));
79
 
80
// Binary String: 0x000102030405
81
print $exporter->export(chr(0) . chr(1) . chr(2) . chr(3) . chr(4) . chr(5));
82
```
83
 
84
Exporting complex types:
85
 
86
```php
87
<?php
88
use SebastianBergmann\Exporter\Exporter;
89
 
90
$exporter = new Exporter;
91
 
92
/*
93
Array &0 (
94
 
95
 
96
        1 => 2
97
        2 => 3
98
    )
99
    1 => Array &2 (
100
 
101
        1 => 0
102
        2 => false
103
    )
104
)
105
*/
106
 
107
print $exporter->export(array(array(1,2,3), array("",0,FALSE)));
108
 
109
/*
110
Array &0 (
111
    'self' => Array &1 (
112
        'self' => Array &1
113
    )
114
)
115
*/
116
 
117
$array = array();
118
$array['self'] = &$array;
119
print $exporter->export($array);
120
 
121
/*
122
stdClass Object &0000000003a66dcc0000000025e723e2 (
123
    'self' => stdClass Object &0000000003a66dcc0000000025e723e2
124
)
125
*/
126
 
127
$obj = new stdClass();
128
$obj->self = $obj;
129
print $exporter->export($obj);
130
```
131
 
132
Compact exports:
133
 
134
```php
135
<?php
136
use SebastianBergmann\Exporter\Exporter;
137
 
138
$exporter = new Exporter;
139
 
140
// Array ()
141
print $exporter->shortenedExport(array());
142
 
143
// Array (...)
144
print $exporter->shortenedExport(array(1,2,3,4,5));
145
 
146
// stdClass Object ()
147
print $exporter->shortenedExport(new stdClass);
148
 
149
// Exception Object (...)
150
print $exporter->shortenedExport(new Exception);
151
 
152
// this\nis\na\nsuper\nlong\nstring\nt...\nspace
153
print $exporter->shortenedExport(
154
<<<LONG_STRING
155
this
156
is
157
a
158
super
159
long
160
string
161
that
162
wraps
163
a
164
lot
165
and
166
eats
167
up
168
a
169
lot
170
of
171
space
172
LONG_STRING
173
);
174
```