1. Go to this page and download the library: Download microparts/errors-php 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/ */
microparts / errors-php example snippets
// Simple example for most cases
use Microparts\Errors\Error;
$error = Error::new($debug = true); // debug parameter add exception trace to http error response.
use Microparts\Errors\Error;
$error = Error::new($debug = true);
try {
throw new PDOException('test');
} catch (Throwable $e) {
return $error->capture($e); // return PSR ResponseInterface
}
// Simple example for most cases
use Microparts\Errors\Error;
use Microparts\Errors\Notify\LoggerNotify;
use Microparts\Errors\Notify\SentryNotify;
use Microparts\Logger\Logger;
use Microparts\Errors\Formatter\DefaultErrorFormatter;
use Microparts\Errors\Handler\DefaultErrorHandler;
$error = new Error($debug = false);
$error->setFormatter(new DefaultErrorFormatter($debug));
$error->setHandler(new DefaultErrorHandler());
$error->addSilentException(LogicException::class); // logic is not a need thing
$error->addDatabaseException(RedisException::class);
// Logger PSR compatible.
// If you want use my pretty logger, just run command:
// composer
use Microparts\Errors\Error;
use Microparts\Errors\Notify\LoggerNotify;
use Microparts\Errors\Notify\SentryNotify;
use Microparts\Logger\Logger;
$error = Error::new();
$error->addNotifier(new LoggerNotify(Logger::new()));
$error->addNotifier(new SentryNotify(['dsn' => $dsn]));
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.