1. Go to this page and download the library: Download ibrahim-kaya/error-tracker 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/ */
ibrahim-kaya / error-tracker example snippets
return [
// Toggle error tracking on/off without uninstalling the package.
// Env key: ERROR_TRACKER_ENABLED
'enabled' => env('ERROR_TRACKER_ENABLED', true),
// Exception classes (and their subclasses) that should NOT be tracked.
'excluded_exceptions' => [
\Illuminate\Validation\ValidationException::class,
\Illuminate\Auth\AuthenticationException::class,
\Illuminate\Session\TokenMismatchException::class,
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class,
\Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException::class,
],
// Dispatch the DB write via a queue worker (true) or synchronously (false).
// Env key: ERROR_TRACKER_QUEUE
'use_queue' => env('ERROR_TRACKER_QUEUE', true),
// Queue name to dispatch jobs onto.
// Env key: ERROR_TRACKER_QUEUE_NAME
'queue' => env('ERROR_TRACKER_QUEUE_NAME', 'default'),
// Store sanitized request input alongside each error.
'log_request_input' => true,
// These request fields are always stripped before storage.
'excluded_input_fields' => [
'password', 'password_confirmation', 'token', '_token',
'credit_card', 'cvv', 'card_number', 'ssn',
],
// Store selected request headers (disabled by default for security).
'log_request_headers' => false,
// Only these headers are ever stored when log_request_headers is true.
'logged_headers' => ['accept', 'accept-language', 'content-type', 'referer', 'origin'],
// Map exception classes to PSR-3 severity levels.
// Uses instanceof — parent classes cover all subclasses.
'severity_map' => [
\Illuminate\Database\QueryException::class => 'critical',
\Illuminate\Database\Eloquent\ModelNotFoundException::class => 'warning',
\Symfony\Component\HttpKernel\Exception\HttpException::class => 'warning',
],
];
use IbrahimKaya\ErrorTracker\Facades\ErrorTracker;
try {
$this->processPayment($order);
} catch (\Exception $e) {
// Capture and continue — will not re-throw
ErrorTracker::capture($e);
return response()->json(['error' => 'Payment failed, please retry.'], 500);
}
use IbrahimKaya\ErrorTracker\Facades\ErrorTracker;
try {
$this->syncInventory();
} catch (\Exception $e) {
// Override the severity level for this specific capture
ErrorTracker::capture($e, ['severity' => 'critical']);
}
try {
$this->sendWelcomeEmail($user);
} catch (\Exception $e) {
report($e); // Works with ErrorTracker automatically
// continue with the request...
}
use IbrahimKaya\ErrorTracker\Models\ErrorLog;
// Get all open errors, most recent first
$errors = ErrorLog::open()->orderByDesc('last_seen_at')->get();
// Get only critical errors
$critical = ErrorLog::withSeverity('critical')->get();
// Get errors for a specific exception class
$queryErrors = ErrorLog::forExceptionClass(\Illuminate\Database\QueryException::class)->get();
// Get errors within a date range
$rangeErrors = ErrorLog::dateRange('2024-01-01', '2024-03-31')->get();
// Find a specific error by fingerprint
$error = ErrorLog::where('fingerprint', $hash)->first();
$error = ErrorLog::find(1);
// Mark as resolved — resolves and records resolved_at
$error->markResolved();
// Mark as ignored — records ignored_at
$error->markIgnored();
// Reopen a resolved or ignored error
$error->reopen();
use IbrahimKaya\ErrorTracker\Models\ErrorLog;
// Counts
ErrorLog::totalErrors(); // Total unique error groups
ErrorLog::totalErrors('open'); // Only open errors
ErrorLog::totalOccurrences(); // Sum of all occurrence counts
ErrorLog::openErrorCount();
ErrorLog::resolvedErrorCount();
ErrorLog::ignoredErrorCount();
// Rankings
ErrorLog::mostFrequent(10); // Top 10 most-occurring errors
ErrorLog::mostRecent(10); // Top 10 most recently seen
// Grouped aggregations
ErrorLog::statisticsByExceptionClass(5); // Top 5 exception classes
ErrorLog::statisticsBySeverity(); // Counts grouped by severity
ErrorLog::statisticsByStatus(); // Counts grouped by status
ErrorLog::statisticsByFile(10); // Top 10 most error-prone files
// Trends
ErrorLog::dailyStatistics(30); // Daily counts for last 30 days
ErrorLog::errorsByDateRange('2024-01-01', '2024-12-31', 'open');
// Dashboard — single call that returns all of the above
$summary = ErrorLog::summaryStatistics(30);
// Returns: total_errors, total_occurrences, open_errors, resolved_errors,
// ignored_errors, by_severity, by_exception_class, most_frequent,
// most_recent, daily_trend
// config/error-tracker.php
'rate_limiting' => [
'enabled' => env('ERROR_TRACKER_RATE_LIMITING', true),
'max_attempts' => 5, // allow up to 5 dispatches per window
'decay_seconds' => 60, // window resets after 60 seconds
],