1. Go to this page and download the library: Download theovdml/doh 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/ */
theovdml / doh example snippets
use DohFormatting\Doh\Doh;
try {
// Some code that throws an exception
throw new RuntimeException("Something went wrong!");
} catch (\Throwable $e) {
$formatter = new Doh($e);
// Get HTML formatted error page (for web display)
echo $formatter->toHtml();
// Get JSON for API response or logging
$json = $formatter->toJson();
// Get JSON:API compliant error document
$jsonApi = $formatter->toJsonApi();
// Plain text (for CLI or logs)
$text = $formatter->toPlainText();
// XML error representation
$xml = $formatter->toXml();
}
$doh = new Doh($exception);
$trace = $doh->buildTrace();
foreach ($trace as $frame) {
echo $frame->getContext() . ' in ' . $frame->getFileLabel() . PHP_EOL;
}