File tree Expand file tree Collapse file tree 3 files changed +55
-5
lines changed Expand file tree Collapse file tree 3 files changed +55
-5
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Tamedevelopers \Database \Capsule ;
6+
7+ use Whoops \Run ;
8+ use Whoops \Handler \PrettyPageHandler ;
9+ use Tamedevelopers \Support \Capsule \Manager ;
10+
11+ class DebugManager{
12+
13+ public static $ whoops ;
14+
15+ /**
16+ * Boot the DebugManager.
17+ * If the constant 'ORMDebugManager' is not defined,
18+ * it defines it and starts the debugger automatically.
19+ *
20+ * So that this is only called once in entire application life cycle
21+ */
22+ public static function boot ()
23+ {
24+ if (!defined ('TAME_DEBUG_MANAGER ' )){
25+ self ::autoStartDebugger ();
26+ define ('TAME_DEBUG_MANAGER ' , 1 );
27+ }
28+ }
29+
30+ /**
31+ * Autostart debugger for error logger
32+ *
33+ * @return string
34+ */
35+ private static function autoStartDebugger ()
36+ {
37+ // if DEBUG MODE IS ON
38+ if (Manager::AppDebug ()){
39+ // header not sent
40+ if (!headers_sent ()) {
41+ // register error handler
42+ self ::$ whoops = new Run ();
43+ self ::$ whoops ->pushHandler (new PrettyPageHandler ());
44+ self ::$ whoops ->register ();
45+ }
46+ }
47+ }
48+
49+ }
Original file line number Diff line number Diff line change @@ -205,8 +205,8 @@ static public function toJsTimer($date)
205205 */
206206 static public function config (?array $ options = [])
207207 {
208- if (!defined ('TIME_TEXT ' )){
209- define ('TIME_TEXT ' , array_merge ([
208+ if (!defined ('TAME_TIME_CONFIG ' )){
209+ define ('TAME_TIME_CONFIG ' , array_merge ([
210210 'night ' => 'Good night! ' ,
211211 'morning ' => 'Good morning! ' ,
212212 'afternoon ' => 'Good afternoon! ' ,
@@ -421,11 +421,11 @@ static public function timeAgo($mode = null)
421421 */
422422 static private function getText ($ mode = null )
423423 {
424- if (!defined ('TIME_TEXT ' )){
424+ if (!defined ('TAME_TIME_CONFIG ' )){
425425 self ::config ();
426426 }
427427
428- return TIME_TEXT [$ mode ] ?? TIME_TEXT ;
428+ return TAME_TIME_CONFIG [$ mode ] ?? TAME_TIME_CONFIG ;
429429 }
430430
431431 /**
Original file line number Diff line number Diff line change 2121 "symfony/var-dumper" : " *" ,
2222 "symfony/console" : " ^6.2" ,
2323 "cocur/slugify" : " ^4.2.0" ,
24- "vlucas/phpdotenv" : " ^5.4.1"
24+ "vlucas/phpdotenv" : " ^5.4.1" ,
25+ "filp/whoops" : " ^2.15"
2526 },
2627 "suggest" : {
2728 "dompdf/dompdf" : " Required to use the `PDF` class and helper (^2.0.2)."
You can’t perform that action at this time.
0 commit comments