PHP code example of webhubworks / laravel-backup-viewer

1. Go to this page and download the library: Download webhubworks/laravel-backup-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/ */

    

webhubworks / laravel-backup-viewer example snippets


// app/Providers/AppServiceProvider.php
use Webhub\BackupViewer\BackupViewer;

public function boot(): void
{
    BackupViewer::auth(function ($request) {
        return $request->user()?->is_admin === true;
    });
}

return [
    'enabled' => true,
    'route' => [
        'path' => 'backups',
        'name' => 'backup-viewer.index',
        'domain' => null,
    ],
    'middleware' => ['web'],
    'download' => [
        'max_bytes' => 500 * 1024 * 1024, // 500 MB cap; null to disable
    ],
    'low_disk_space_threshold' => 0.15, // warn when < 15% free
    'monitor_stale_after_minutes' => 1440, // 24h
    'favicon' => [
        'html' => null, // raw <link ...> block pasted from your main layout
        'path' => null, // OR a single href like '/favicon.svg'
    ],
];

'favicon' => [
    'html' => <<<'HTML'
        <link rel="apple-touch-icon" sizes="180x180" href="/meta/apple-touch-icon.png">
        <link rel="icon" type="image/png" sizes="32x32" href="/meta/favicon-32x32.png">
        <link rel="manifest" href="/meta/site.webmanifest">
    HTML,
    'path' => null,
],

// routes/console.php
use Illuminate\Support\Facades\Schedule;

Schedule::command('backup:clean')->daily()->at('01:00')->onOneServer();
Schedule::command('backup:run --only-db')->daily()->at('02:00')->onOneServer();
Schedule::command('backup:run --only-files')->daily()->at('03:00')->onOneServer();
Schedule::command('backup:monitor')->daily()->at('04:00')->onOneServer();
bash
php artisan vendor:publish --tag=backup-viewer-config
bash
php artisan vendor:publish --tag=backup-viewer-config