1. Go to this page and download the library: Download maplephp/blunder library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
maplephp / blunder example snippets
use MaplePHP\Blunder\Run;
use MaplePHP\Blunder\Handlers\HtmlHandler;
$run = new Run(new HtmlHandler());
$run->load();
$run = new Run(new HtmlHandler());
$run->severity()->excludeSeverityLevels([E_DEPRECATED, E_USER_DEPRECATED]);
$run->load();
$run = new Run(new HtmlHandler());
$run->severity()
->excludeSeverityLevels([E_WARNING, E_USER_WARNING])
->redirectTo(function ($errNo, $errStr, $errFile, $errLine) {
error_log("Custom log: $errStr in $errFile on line $errLine");
return true; // Suppresses output for excluded severities
});
$run = new Run($errorHandler);
$run->severity()
->excludeSeverityLevels([E_WARNING, E_USER_WARNING])
->redirectTo(function ($errNo, $errStr, $errFile, $errLine) {
return new JsonHandler();
});
$handler = new CliHandler();
// Enable or disable trace lines
$handler->enableTraceLines(true); // Set false to disable
$run = new Run($handler);
$run->load();
$run = new Run(new HtmlHandler());
$run->removeLocationHeader(true);
$run->load();
$run = new Run(new CliHandler());
$run->setExitCode(1);
$run->load();
// Add the namespaces
use MaplePHP\Blunder\Run;
use MaplePHP\Blunder\Handlers\HtmlHandler;
use MaplePHP\Blunder\Handlers\SilentHandler;
use MaplePHP\Log\Logger;
use MaplePHP\Log\Handlers\StreamHandler;
// Bool to switch between dev and prod mode
$production = true;
// Initialize Blunder
$handler = ($production ? new SilentHandler() : new HtmlHandler());
$run = new Run($handler);
// Create the event
$run->event(function($item, $http) use($production) {
if ($production) {
// Initialize the MaplePHP PSR-3 compliant log library
$log = new Logger(new StreamHandler("/path/to/errorLogFile.log", StreamHandler::MAX_SIZE, StreamHandler::MAX_COUNT));
// The code below uses "getStatus" to call PSR-3 log methods like $log->error() or $log->warning().
call_user_func_array([$log, $item->getStatus()], [
$item->getMessage(),
[
'flag' => $item->getSeverity(),
'file' => $item->getFile(),
'line' => $item->getLine()
]
]);
}
});
// Load the error handling, and done
$run->load();
// $run = new Run(HandlerInterface, HttpMessagingInterface(ResponseInterface, ServerRequestInterface));
$run = new Run(new HtmlHandler(), new HttpMessaging($response, $request));
try {
// An exception has been triggered inside dispatch()
$dispatch = $row->dispatch();
} catch (Throwable $e) {
// By default, rethrowing with a new exception class changes the error location
$exception = new RuntimeException($e->getMessage(), (int) $e->getCode());
// Preserve the original exception's file and line number
if (method_exists($e, "preserveExceptionOrigin")) {
$e->preserveExceptionOrigin($exception);
}
throw $exception;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.