1. Go to this page and download the library: Download oshco/db-exceptions-logger 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/ */
oshco / db-exceptions-logger example snippets
use Oshco\ErrHandler\DatabaseErrHandler;
use Oshco\Infrastructure\Repository\ExceptionsRepository;
use WebFiori\Database\Database;
use WebFiori\Error\Handler;
use WebFiori\Framework\App;
$db = new Database(App::getConfig()->getDBConnection('your-connection'));
$repo = new ExceptionsRepository($db);
Handler::registerHandler(new DatabaseErrHandler($repo));
use Oshco\ErrHandler\DatabaseErrHandler;
use WebFiori\Framework\Session\SessionsManager;
DatabaseErrHandler::setPortalIdResolver(function () {
$session = SessionsManager::getActiveSession();
return $session?->get('portal-id');
});
use Oshco\Infrastructure\Repository\ExceptionsRepository;
use WebFiori\Database\Database;
use WebFiori\Framework\App;
$db = new Database(App::getConfig()->getDBConnection('your-connection'));
$repo = new ExceptionsRepository($db);
// Get total count
$count = $repo->count();
// Get paginated list (page 1, 10 per page)
$exceptions = $repo->getAll(1, 10);
// Get by ID
$exception = $repo->getById(1);
// Get the most recent exception
$latest = $repo->getLast();
// Check if an exception with a given hash exists
$exists = $repo->existsByHash($hashString);
// Filter by portal
$portalExceptions = $repo->getByPortal(portalId: 1, page: 1, size: 10);
$portalCount = $repo->countByPortal(portalId: 1);
// Count by exception class
$stats = $repo->getStatsByExceptionClass('2026-01-01', '2026-12-31', limit: 10);
// Count by class + line (pinpoints exact code location)
$stats = $repo->getStatsByClassAndLine();
// Count by portal
$stats = $repo->getStatsByPortal();
// Count by URL (which endpoints fail most)
$stats = $repo->getStatsByUrl();
// Daily error trend
$stats = $repo->getStatsByDay('2026-06-01', '2026-06-30');
// Top recurring errors (grouped by hash)
$stats = $repo->getTopRecurring();
// Total count in date range
$count = $repo->countInRange('2026-06-01', '2026-06-30');