PHP code example of laboiteacode / filament-logs-explorer

1. Go to this page and download the library: Download laboiteacode/filament-logs-explorer 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/ */

    

laboiteacode / filament-logs-explorer example snippets


use LaBoiteACode\FilamentLogsExplorer\FilamentLogsExplorerPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->plugin(FilamentLogsExplorerPlugin::make());
}

// config/filament-logs-explorer.php
'channels' => ['daily', 'single'],  // empty array => auto-discover
'exclude_channels' => ['emergency'],
'expand_stacks' => true,            // expand "stack" channels into their members
'files_per_channel' => 15,

FilamentLogsExplorerPlugin::make()
    ->channels(['daily', 'single'])
    ->excludeChannels(['emergency'])
    ->expandStacks()
    ->filesPerChannel(20);

'discover_untracked_files' => true,
'log_directory' => null,             // null => storage_path('logs')
'untracked_channel_label' => null,   // null => the translated label

FilamentLogsExplorerPlugin::make()
    ->discoverUntrackedFiles(directory: storage_path('logs'));

FilamentLogsExplorerPlugin::make()
    ->navigationLabel('Application logs')
    ->navigationIcon('heroicon-o-bug-ant')
    ->activeNavigationIcon('heroicon-s-bug-ant')
    ->navigationGroup('System')
    ->navigationSort(99)
    ->navigationParentItem('Tools')
    ->navigationBadge()          // show the number of channels as a badge
    ->registerNavigation(false)  // keep the route, hide the menu entry
    ->slug('application-logs');

FilamentLogsExplorerPlugin::make()
    ->cluster(SystemCluster::class);

'authorization' => [
    'gate' => 'view-logs',
],

FilamentLogsExplorerPlugin::make()
    ->canAccessUsing(fn (): bool => auth()->user()?->can('viewLogs') ?? false);

'deletion' => [
    'enabled' => true,
    'gate' => 'delete-logs',  // null => anyone who can access the page
],

// Hide the delete buttons entirely.
FilamentLogsExplorerPlugin::make()->deletable(false);

// Or decide per user.
FilamentLogsExplorerPlugin::make()
    ->canDeleteUsing(fn (): bool => auth()->user()?->can('deleteLogs') ?? false);

'reader' => [
    'max_bytes' => 5 * 1024 * 1024,
    'tail_when_exceeded' => true,
],

FilamentLogsExplorerPlugin::make()
    ->maxBytes(10 * 1024 * 1024)
    ->tailWhenExceeded();
bash
php artisan filament:assets
bash
# config/filament-logs-explorer.php
php artisan vendor:publish --tag="filament-logs-explorer-config"

# lang/vendor/filament-logs-explorer/{locale}/filament-logs-explorer.php
php artisan vendor:publish --tag="filament-logs-explorer-translations"

# resources/views/vendor/filament-logs-explorer/
php artisan vendor:publish --tag="filament-logs-explorer-views"
bash
php artisan vendor:publish --tag="filament-logs-explorer-translations"