PHP code example of devorto / exception-handler
1. Go to this page and download the library: Download devorto/exception-handler 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/ */
devorto / exception-handler example snippets
// Init ExceptionHandler class:
\Devorto\ExceptionHandler::init();
// Add a logger.
\Devorto\ExceptionHandler::addLogger(new AnyLoggerImplementingLoggerInterface());
// This class removes the need of using `@` before php standard methods because we can now catch and continue with our code but still log that this happened.
try {
mkdir('/existing-path-which-results-in-a-notice');
} catch (ErrorException $exception) {
// Log "caught" exception.
\Devorto\ExceptionHandler::log($exception);
}
/**
* This will result in a HTTP 500 Error Page.
* This will however be logged using the exception handler and provided loggers.
*/
throw new Exception('It broke!');