hydephp /
develop
| 1 | <?php |
||||
| 2 | |||||
| 3 | try { |
||||
| 4 | define('BASE_PATH', isset($_SERVER['HERD_SITE_PATH']) ? realpath($_SERVER['HERD_SITE_PATH']) : realpath(getcwd())); |
||||
| 5 | define('HYDE_START', microtime(true)); |
||||
| 6 | |||||
| 7 | if (isset($_SERVER['HERD_SITE_PATH'])) { |
||||
| 8 | chdir($_SERVER['HERD_SITE_PATH']); |
||||
| 9 | } |
||||
| 10 | |||||
| 11 | require getenv('HYDE_AUTOLOAD_PATH') ?: BASE_PATH.'/vendor/autoload.php'; |
||||
| 12 | |||||
| 13 | try { |
||||
| 14 | $app = \Desilva\Microserve\Microserve::boot(\Hyde\RealtimeCompiler\Http\HttpKernel::class); |
||||
| 15 | $response = $app->handle(); |
||||
| 16 | } catch (Throwable $exception) { |
||||
| 17 | \Hyde\RealtimeCompiler\Http\ExceptionHandler::handle($exception)->send(); |
||||
| 18 | } |
||||
| 19 | } catch (\Throwable $throwable) { |
||||
| 20 | // Auxiliary exception handler |
||||
| 21 | echo '<h1>Something went really wrong!</h1>'; |
||||
| 22 | echo '<p>An error occurred that the core exception handler failed to process. Here\'s all we know:</p>'; |
||||
| 23 | echo '<h2>Initial exception:</h2><pre>'.print_r($exception ?? null, true).'</pre>'; |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 24 | echo '<h2>Auxiliary exception:</h2><pre>'.print_r($throwable, true).'</pre>'; |
||||
|
0 ignored issues
–
show
Are you sure
print_r($throwable, true) of type string|true can be used in concatenation?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 25 | } finally { |
||||
| 26 | if (getenv('HYDE_SERVER_REQUEST_OUTPUT')) { |
||||
| 27 | // Write to console to emulate the standard built-in PHP server output |
||||
| 28 | $request = \Desilva\Microserve\Request::capture(); |
||||
| 29 | file_put_contents('php://stderr', sprintf( |
||||
| 30 | "[%s] %s [%d]: %s %s\n", |
||||
| 31 | date('D M j H:i:s Y'), |
||||
| 32 | str_replace('::1', '[::1]', $_SERVER['REMOTE_ADDR']).':'.$_SERVER['REMOTE_PORT'], |
||||
| 33 | $response->statusCode ?? ((isset($exception) && $exception->getCode() >= 400) ? $exception->getCode() : 500), |
||||
| 34 | $request->method, |
||||
| 35 | $request->path, |
||||
| 36 | )); |
||||
| 37 | } |
||||
| 38 | |||||
| 39 | if (isset($exception)) { |
||||
| 40 | exit($exception->getCode()); |
||||
| 41 | } |
||||
| 42 | } |
||||
| 43 |