-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugger.php
More file actions
64 lines (55 loc) · 1.58 KB
/
Debugger.php
File metadata and controls
64 lines (55 loc) · 1.58 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* This file is part of Blitz PHP framework.
*
* (c) 2022 Dimitri Sitchet Tomkeu <devcode.dst@gmail.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace BlitzPHP\Debug;
use Spatie\Ignition\Ignition;
use Whoops\Run;
/**
* Capture et affiche les erreurs et exceptions via whoops
*
* Necessite l'instalation de `flip/whoops` ou `spatie/ignition`
*/
class Debugger
{
/**
* Demarre le processus
*/
public static function init(): void
{
$config = config('exceptions');
if (class_exists(Ignition::class)) {
self::initIgnition($config);
} elseif (class_exists(Run::class)) {
self::initWhoops($config);
}
}
/**
* Initialisation du debugger a travers filp/Whoops
*/
private static function initWhoops(array $config): void
{
$debugger = new Run();
$debugger = ExceptionManager::registerWhoopsHandler($debugger, $config);
$debugger = ExceptionManager::registerHttpErrors($debugger, $config);
$debugger = ExceptionManager::registerAppHandlers($debugger, $config);
$debugger->register();
}
/**
* Initialisation du debugger a travers spatie/ignition
*
* @todo customisation du debugger et log des erreurs
*/
private static function initIgnition(array $config): void
{
$debugger = Ignition::make();
$debugger->applicationPath(ROOTPATH)
->shouldDisplayException(! on_prod())
->register();
}
}