|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/** |
| 6 | + * This file is part of the Phalcon Kit. |
| 7 | + * |
| 8 | + * (c) Phalcon Kit Team |
| 9 | + * |
| 10 | + * For the full copyright and license information, please view the LICENSE.txt |
| 11 | + * file that was distributed with this source code. |
| 12 | + */ |
| 13 | + |
| 14 | +use PhalconKit\Support\Debug; |
| 15 | + |
| 16 | +require dirname(__DIR__) . '/vendor/autoload.php'; |
| 17 | + |
| 18 | +$remoteAddr = $_SERVER['REMOTE_ADDR'] ?? '127.0.0.1'; |
| 19 | + |
| 20 | +if (!in_array($remoteAddr, ['127.0.0.1', '::1'], true)) { |
| 21 | + http_response_code(403); |
| 22 | + header('Content-Type: text/plain; charset=UTF-8'); |
| 23 | + echo "This debug test page is available from localhost only.\n"; |
| 24 | + |
| 25 | + return; |
| 26 | +} |
| 27 | + |
| 28 | +function phalconKitDebugTestLeaf(): never |
| 29 | +{ |
| 30 | + throw new InvalidArgumentException('Synthetic previous exception for the PhalconKit debug page.'); |
| 31 | +} |
| 32 | + |
| 33 | +function phalconKitDebugTestEntry(): never |
| 34 | +{ |
| 35 | + try { |
| 36 | + phalconKitDebugTestLeaf(); |
| 37 | + } |
| 38 | + catch (Throwable $throwable) { |
| 39 | + throw new RuntimeException('Synthetic PhalconKit debug output test exception.', 0, $throwable); |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +$debug = new Debug(); |
| 44 | +$debug |
| 45 | + ->setUri('./') |
| 46 | + ->setShowFileFragment(true) |
| 47 | + ->debugVar([ |
| 48 | + 'purpose' => 'Manual PhalconKit debug renderer smoke test', |
| 49 | + 'phalcon' => phpversion('phalcon') ?: 'not installed', |
| 50 | + 'php' => PHP_VERSION, |
| 51 | + 'request' => [ |
| 52 | + 'uri' => $_SERVER['REQUEST_URI'] ?? null, |
| 53 | + 'remoteAddr' => $remoteAddr, |
| 54 | + ], |
| 55 | + ]); |
| 56 | + |
| 57 | +try { |
| 58 | + phalconKitDebugTestEntry(); |
| 59 | +} |
| 60 | +catch (Throwable $throwable) { |
| 61 | + http_response_code(500); |
| 62 | + echo $debug->renderHtml($throwable); |
| 63 | +} |
0 commit comments