Skip to content

Commit ded4415

Browse files
committed
sync
1 parent 23c53b1 commit ded4415

14 files changed

Lines changed: 160 additions & 534 deletions

File tree

index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
// --------------------------------------------------------------
2424
// Jalankan frameworknya.
2525
// --------------------------------------------------------------
26-
require path('system') . 'boot.php';
26+
require path('system') . 'boot.php';

system/boot.php

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,39 @@
1313

1414
require __DIR__ . DS . 'init.php';
1515

16+
/*
17+
|--------------------------------------------------------------------------
18+
| Muat helpers dan autoloader awal untuk debugger
19+
|--------------------------------------------------------------------------
20+
|
21+
| Muat helpers dan autoloader sebelum core untuk inisialisasi debugger early.
22+
|
23+
*/
24+
25+
require path('system') . 'helpers.php';
26+
require_once path('system') . 'autoloader.php';
27+
spl_autoload_register(['\System\Autoloader', 'load']);
28+
\System\Autoloader::namespaces(['System' => path('system')]);
29+
30+
/*
31+
|--------------------------------------------------------------------------
32+
| Inisialisasi debugger awal
33+
|--------------------------------------------------------------------------
34+
|
35+
| Enable debugger sebelum boot package untuk tangkap error early seperti
36+
| koneksi Redis yang gagal saat session init.
37+
|
38+
*/
39+
40+
use System\Foundation\Oops\Debugger;
41+
42+
if (file_exists($debugger = path('app') . 'config' . DS . 'debugger.php')) {
43+
$debugger = require $debugger;
44+
Debugger::$productionMode = (false === (bool) $debugger['activate']);
45+
Debugger::enable(null, path('storage') . 'logs');
46+
unset($debugger);
47+
}
48+
1649
/*
1750
|--------------------------------------------------------------------------
1851
| Jalankan Core Boot
@@ -27,6 +60,31 @@
2760

2861
require __DIR__ . DS . 'core.php';
2962

63+
/*
64+
|--------------------------------------------------------------------------
65+
| Load Config Debugger Base
66+
|--------------------------------------------------------------------------
67+
|
68+
| Load base config debugger untuk set productionMode sebelum enable,
69+
| agar error early tidak tampil HTML debugger.
70+
|
71+
*/
72+
73+
$debugger = require path('app') . 'config' . DS . 'debugger.php';
74+
Debugger::$productionMode = (false === (bool) $debugger['activate']);
75+
unset($debugger);
76+
77+
/*
78+
|--------------------------------------------------------------------------
79+
| Enable Debugger Lebih Awal
80+
|--------------------------------------------------------------------------
81+
|
82+
| Enable debugger sebelum boot package untuk tangkap error early seperti
83+
| koneksi Redis yang gagal saat session init.
84+
|
85+
*/
86+
87+
Debugger::enable(null, path('storage') . 'logs');
3088
/*
3189
|--------------------------------------------------------------------------
3290
| Mulai Paket 'application'
@@ -47,37 +105,32 @@
47105
|--------------------------------------------------------------------------
48106
|
49107
| Atur konfigurasi debugger sesuai data yang diberikan user di file
50-
| application/config/debugger.php.
108+
| application/config/debugger.php. Config sudah dimuat awal, tapi set ulang
109+
| untuk memastikan konsistensi setelah package boot.
51110
|
52111
*/
53112

54-
use System\Foundation\Oops\Debugger;
55-
56-
Debugger::enable(false, path('storage') . 'logs');
57-
58-
$debugger = Config::get('debugger');
113+
$debugger = Config::get('debugger'); // Gunakan Config::get untuk konsistensi
59114
$template = path('app') . 'views' . DS . 'error' . DS . '500.blade.php';
60115

116+
// ProductionMode sudah di-set awal, tapi pastikan sesuai config
61117
Debugger::$productionMode = (false === (bool) $debugger['activate']);
62118
Debugger::$strictMode = (bool) $debugger['strict'];
63119
Debugger::$scream = (bool) $debugger['scream'];
64120

65-
Debugger::$showFirelog = false;
66121
Debugger::$logSeverity = 0;
67122
Debugger::$errorTemplate = is_file($template) ? $template : null;
68123
Debugger::$time = RAKIT_START;
69-
Debugger::$editor = false;
70-
Debugger::$editorMapping = [];
71-
Debugger::$customCssFiles = [];
72-
Debugger::$customJsFiles = [];
124+
125+
73126

74127
Debugger::$showBar = (bool) $debugger['debugbar'];
75128
Debugger::$showLocation = (bool) $debugger['location'];
76129
Debugger::$maxDepth = (int) $debugger['depth'];
77130
Debugger::$maxLength = (int) $debugger['length'];
78131
Debugger::$email = (string) $debugger['email'];
79132

80-
unset($debugger, $template);
133+
unset($debugger, $template, $debugger);
81134

82135
/*
83136
|--------------------------------------------------------------------------

system/core.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
require path('system') . 'package.php';
4545
require path('system') . 'config.php';
4646
require path('system') . 'helpers.php';
47-
require path('system') . 'autoloader.php';
47+
require_once path('system') . 'autoloader.php';
4848
require path('system') . 'request.php';
4949
require path('system') . 'response.php';
5050
require path('system') . 'blade.php';

system/foundation/oops/assets/bar/errors.panel.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ defined('DS') or exit('No direct access.');
1212
<tr>
1313
<td class="oops-right"><?php echo $count ? "$count\xC3\x97" : '' ?></td>
1414
<td>
15-
<pre><?php echo Helpers::escapeHtml($message), ' in ', Helpers::editorLink($file, $line) ?></pre>
15+
<pre><?php echo Helpers::escapeHtml($message), ' in ', '<span>', $file . ($line ? ":$line" : ''), '</span>' ?></pre>
1616
</td>
1717
</tr>
1818
<?php endforeach ?>

system/foundation/oops/assets/panic/content.phtml

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ $code = $e->getCode() ? ' #' . $e->getCode() : '';
7373
<h2><a data-oops-ref="^+" class="oops-toggle<?php echo ($collapsed = $expanded !== null) ? ' oops-collapsed' : '' ?>">Source file</a></h2>
7474

7575
<div class="<?php echo $collapsed ? 'oops-collapsed ' : '' ?>inner">
76-
<p><b>File:</b> <?php echo Helpers::editorLink($ex->getFile(), $ex->getLine()) ?></p>
76+
<p><b>File:</b> <span><?php echo $ex->getFile() . ($ex->getLine() ? ":$ex->getLine()" : '') ?></span></p>
7777
<?php if (is_file($ex->getFile())) : ?>
7878
<?php $ctx = (in_array(get_class($ex), ['ErrorException', '\ErrorException']) || $ex instanceof \ErrorException) ? \System\Foundation\Oops\Context::getContext($ex) : null; ?>
7979
<?php echo self::highlightFile($ex->getFile(), $ex->getLine(), 15, is_array($ctx) ? $ctx : []); ?>
@@ -87,62 +87,8 @@ $code = $e->getCode() ? ' #' . $e->getCode() : '';
8787
<h2><a data-oops-ref="^+" class="oops-toggle">Call stack</a></h2>
8888

8989
<div class="inner">
90-
<ol>
91-
<?php foreach ($stack as $key => $row) : ?>
92-
<li>
93-
<p>
94-
<?php if (isset($row['file']) && is_file($row['file'])) : ?>
95-
<?php echo Helpers::editorLink($row['file'], $row['line']) ?>
96-
<?php else : ?>
97-
<i>inner-code</i><?php if (isset($row['line'])) echo ':', $row['line'] ?>
98-
<?php endif ?>
99-
100-
<?php if (isset($row['file']) && is_file($row['file'])) : ?><a data-oops-ref="^p + .file" class="oops-toggle<?php if ($expanded !== $key) echo ' oops-collapsed' ?>">source</a>&nbsp; <?php endif ?>
101-
102-
<?php
103-
if (isset($row['object'])) echo "<a data-oops-ref='^p + .object' class='oops-toggle oops-collapsed'>";
104-
if (isset($row['class'])) echo Helpers::escapeHtml($row['class'] . $row['type']);
105-
if (isset($row['object'])) echo '</a>';
106-
echo Helpers::escapeHtml($row['function']), '(';
107-
if (!empty($row['args'])) : ?><a data-oops-ref="^p + .args" class="oops-toggle oops-collapsed">arguments</a><?php endif ?>)
108-
</p>
109-
110-
<?php if (isset($row['file']) && is_file($row['file'])) : ?>
111-
<div class="<?php if ($expanded !== $key) echo 'oops-collapsed ' ?>file"><?php echo self::highlightFile($row['file'], $row['line']) ?></div>
112-
<?php endif ?>
113-
114-
<?php if (isset($row['object'])) : ?>
115-
<div class="oops-collapsed outer object"><?php echo $dump($row['object']) ?></div>
116-
<?php endif ?>
117-
118-
<?php if (!empty($row['args'])) : ?>
119-
<div class="oops-collapsed outer args">
120-
<table>
121-
<?php
122-
try {
123-
$r = isset($row['class'])
124-
? new \ReflectionMethod($row['class'], $row['function'])
125-
: new \ReflectionFunction($row['function']);
126-
$params = $r->getParameters();
127-
} catch (\Throwable $e) {
128-
$params = [];
129-
} catch (\Exception $e) {
130-
$params = [];
131-
}
132-
133-
foreach ($row['args'] as $k => $v) {
134-
echo '<tr><th>', Helpers::escapeHtml(isset($params[$k]) ? '$' . $params[$k]->name : "#$k"), '</th><td>';
135-
echo $dump($v, isset($params[$k]) ? $params[$k]->name : null);
136-
echo "</td></tr>\n";
137-
}
138-
?>
139-
</table>
140-
</div>
141-
<?php endif ?>
142-
</li>
143-
<?php endforeach ?>
144-
</ol>
145-
</div>
90+
<p>Call stack: <?php echo count($stack) ?> frames</p>
91+
</div>
14692
</div>
14793
<?php endif ?>
14894

system/foundation/oops/bar.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,12 @@ public function dispatchAssets()
252252

253253
private function renderAssets()
254254
{
255-
$css = array_map('file_get_contents', array_merge([
255+
$css = array_map('file_get_contents', [
256256
__DIR__ . '/assets/bar/bar.css',
257257
__DIR__ . '/assets/toggle/toggle.css',
258258
__DIR__ . '/assets/dumper/dumper.css',
259259
__DIR__ . '/assets/panic/panic.css',
260-
], Debugger::$customCssFiles));
260+
]);
261261

262262
echo "(function(){
263263
var el = document.createElement('style');
@@ -266,11 +266,11 @@ private function renderAssets()
266266
el.textContent=" . json_encode(preg_replace('#\s+#u', ' ', implode($css))) . ";
267267
document.head.appendChild(el);})();\n";
268268

269-
array_map('readfile', array_merge([
269+
array_map('readfile', [
270270
__DIR__ . '/assets/bar/bar.js',
271271
__DIR__ . '/assets/toggle/toggle.js',
272272
__DIR__ . '/assets/dumper/dumper.js',
273273
__DIR__ . '/assets/panic/panic.js',
274-
], Debugger::$customJsFiles));
274+
]);
275275
}
276276
}

0 commit comments

Comments
 (0)