1. Go to this page and download the library: Download kadiaak/log-viewer 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/ */
kadiaak / log-viewer example snippets
use Illuminate\Support\Facades\Gate;
public function boot(): void
{
Gate::define('viewLogViewer', function ($user = null) {
return in_array(optional($user)->email, [
'[email protected]',
]);
});
}
use Kadiaak\LogViewer\Facades\LogViewer;
// All discovered files
$files = LogViewer::files();
// A single file + a paginated, filtered scan
$file = LogViewer::files()->first();
$result = $file->scan([
'query' => '/SQLSTATE\[\d+\]/', // plain text or /regex/
'levels' => ['error', 'critical'],
'page' => 1,
'per_page' => 50,
'direction' => 'desc',
]);
// $result['entries'], $result['level_counts'], $result['pagination']