-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdumper.php
40 lines (35 loc) · 1.3 KB
/
dumper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\ServerDumper;
use Symfony\Component\VarDumper\Dumper\ContextProvider\CliContextProvider;
use Symfony\Component\VarDumper\Dumper\ContextProvider\RequestContextProvider;
use Symfony\Component\VarDumper\Dumper\ContextProvider\SourceContextProvider;
use Symfony\Component\VarDumper\VarDumper;
if (!class_exists('Symfony\Component\VarDumper\Dumper\ServerDumper')) {
require_once '/opt/var-dumper/vendor/autoload.php';
}
if (!function_exists('dumps')) {
function dumps($var, ...$moreVars) {
$cloner = new VarCloner();
$contextProviders = [
'cli' => new CliContextProvider(),
'source' => new SourceContextProvider(),
];
$dumper = new ServerDumper($_SERVER['VAR_DUMPER_SERVER'] ?? '127.0.0.1:9912');
$handler = function ($var) use ($cloner, $dumper) {
$dumper->dump($cloner->cloneVar($var));
};
$originalHandler = VarDumper::setHandler($handler);
VarDumper::dump($var);
foreach ($moreVars as $var) {
VarDumper::dump($var);
}
// Make sure that any subsequent call go to the previously configured
// handler rather than to the server.
VarDumper::setHandler($originalHandler);
if (1 < func_num_args()) {
return func_get_args();
}
return $var;
}
}