Mempermudah proses debugging, logging, dan optimasi performa.
// Di Controller
public function example(): void {
$data = [
'user' => 'John Doe',
'roles' => ['admin', 'editor']
];
$this->dump($data); // Menampilkan data dalam format yang mudah dibaca
$this->dump($data, 'User Data'); // Dengan label
}
// Debugging request data
public function handleForm(): void {
$this->debugRequest(); // Menampilkan semua data request (GET, POST, FILES)
// Atau specific data
$this->debugRequest('POST'); // Hanya data POST
$this->debugRequest('GET'); // Hanya data GET
}
// Menampilkan raw output tanpa processing template
$this->Raw($data); // Output data langsung ke browser
$this->Raw($data, true); // Dengan pretty print untuk array/object
// Basic logging
$this->log('User login attempt');
// Dengan level dan context
$this->log('Payment processed', 'info', [
'user_id' => 123,
'amount' => 99.99
]);
// Error logging
try {
// some code
} catch (Exception $e) {
$this->log($e->getMessage(), 'error', [
'file' => $e->getFile(),
'line' => $e->getLine()
]);
}
debug
: Detailed debug informationinfo
: Interesting eventsnotice
: Normal but significant eventswarning
: Exceptional occurrences that are not errorserror
: Runtime errorscritical
: Critical conditionsalert
: Action must be taken immediatelyemergency
: System is unusable
// Clear all UI cache
$this->clearUICache();
// Clear specific cache
$this->clearUICache('templates');
$this->clearUICache('assets');
// In configuration
'cache' => [
'enabled' => true,
'path' => 'cache/',
'lifetime' => 3600, // 1 hour
'compress' => true
]
// Standardize HTML output
$html = $this->html_standard($content);
// With options
$html = $this->html_standard($content, [
'remove_comments' => true,
'compress' => true,
'fix_tags' => true
]);
// Start monitoring
$this->startTimer('database-query');
// Some database operations
$results = $db->query(...);
// End monitoring
$time = $this->endTimer('database-query');
$this->log("Query execution time: {$time}ms", 'debug');
// Get memory usage
$memory = $this->getMemoryUsage();
$this->log("Current memory usage: {$memory}MB");
// Get peak memory
$peak = $this->getPeakMemoryUsage();
$this->log("Peak memory usage: {$peak}MB");
// config/debug.php
return [
'debug' => [
'enabled' => env('APP_DEBUG', false),
'log_level' => env('APP_LOG_LEVEL', 'warning'),
'display_errors' => env('APP_DISPLAY_ERRORS', false),
'log_path' => 'storage/logs/',
'pretty_print' => true,
'max_log_files' => 30,
'log_format' => 'Y-m-d H:i:s'
]
];