|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace App\Application\Bootloader; |
|
6
|
|
|
|
|
7
|
|
|
use App\Application\Exception\Renderer\ViewRenderer; |
|
8
|
|
|
use Spiral\Boot\AbstractKernel; |
|
|
|
|
|
|
9
|
|
|
use Spiral\Boot\Bootloader\Bootloader; |
|
|
|
|
|
|
10
|
|
|
use Spiral\Exceptions\ExceptionHandler; |
|
|
|
|
|
|
11
|
|
|
use Spiral\Exceptions\Renderer\ConsoleRenderer; |
|
|
|
|
|
|
12
|
|
|
use Spiral\Exceptions\Renderer\JsonRenderer; |
|
|
|
|
|
|
13
|
|
|
use Spiral\Exceptions\Reporter\FileReporter; |
|
|
|
|
|
|
14
|
|
|
use Spiral\Exceptions\Reporter\LoggerReporter; |
|
|
|
|
|
|
15
|
|
|
use Spiral\Http\ErrorHandler\RendererInterface; |
|
|
|
|
|
|
16
|
|
|
use Spiral\Http\Middleware\ErrorHandlerMiddleware\EnvSuppressErrors; |
|
|
|
|
|
|
17
|
|
|
use Spiral\Http\Middleware\ErrorHandlerMiddleware\SuppressErrorsInterface; |
|
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* The exception handler bootloader is responsible for registering the exception renderers and reporters. |
|
21
|
|
|
* |
|
22
|
|
|
* @link https://spiral.dev/docs/basics-errors |
|
23
|
|
|
*/ |
|
24
|
|
|
final class ExceptionHandlerBootloader extends Bootloader |
|
25
|
|
|
{ |
|
26
|
|
|
protected const BINDINGS = [ |
|
27
|
|
|
SuppressErrorsInterface::class => EnvSuppressErrors::class, |
|
28
|
|
|
RendererInterface::class => ViewRenderer::class, |
|
29
|
|
|
]; |
|
30
|
|
|
|
|
31
|
|
|
public function __construct( |
|
32
|
|
|
private readonly ExceptionHandler $handler, |
|
33
|
|
|
) { |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function init(AbstractKernel $kernel): void |
|
37
|
|
|
{ |
|
38
|
|
|
// Register the console renderer, that will be used when the application |
|
39
|
|
|
// is running in the console. |
|
40
|
|
|
$this->handler->addRenderer(new ConsoleRenderer()); |
|
41
|
|
|
|
|
42
|
|
|
$kernel->running(function (): void { |
|
43
|
|
|
// Register the JSON renderer, that will be used when the application is |
|
44
|
|
|
// running in the HTTP context and a JSON response is expected. |
|
45
|
|
|
$this->handler->addRenderer(new JsonRenderer()); |
|
46
|
|
|
}); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function boot(LoggerReporter $logger, FileReporter $files): void |
|
50
|
|
|
{ |
|
51
|
|
|
// Register the logger reporter, that will be used to log the exceptions using |
|
52
|
|
|
// the logger component. |
|
53
|
|
|
$this->handler->addReporter($logger); |
|
54
|
|
|
|
|
55
|
|
|
// Register the file reporter. It allows you to save detailed information about an exception to a file |
|
56
|
|
|
// known as snapshot. |
|
57
|
|
|
$this->handler->addReporter($files); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths