forked from xrdebug/php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo-throwable.php
49 lines (43 loc) · 1.14 KB
/
demo-throwable.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
41
42
43
44
45
46
47
48
49
<?php
/**
* This file is part of Swow-Cloud/Job
* @license https://github.com/serendipity-swow/serendipity-job/blob/master/LICENSE
*/
declare(strict_types=1);
use Chevere\ThrowableHandler\ThrowableHandler;
use Chevere\Writer\StreamWriter;
use Chevere\Writer\Writers;
use Chevere\Writer\WritersInstance;
use function Chevere\Writer\streamFor;
use function Chevere\Xr\registerThrowableHandler;
foreach (['/', '/../../../'] as $path) {
$autoload = __DIR__ . $path . 'vendor/autoload.php';
if (stream_resolve_include_path($autoload)) {
require $autoload;
break;
}
}
new WritersInstance(
(new Writers())
->withOutput(
new StreamWriter(
streamFor('php://stdout', 'w')
)
)
->withError(
new StreamWriter(
streamFor('php://stderr', 'w')
)
)
);
set_error_handler(
ThrowableHandler::ERRORS_AS_EXCEPTIONS
);
register_shutdown_function(
ThrowableHandler::FATAL_ERROR_HANDLER
);
set_exception_handler(
ThrowableHandler::CONSOLE_HANDLER
);
registerThrowableHandler(true);
include __DIR__ . '/demo/runtime-exception.php';