PHP code example of devifyo / watchtower

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

    

devifyo / watchtower example snippets


  // routes/console.php (Laravel 11/12) or app/Console/Kernel.php
  $schedule->command('watchtower:prune')->daily();
  

use Illuminate\Support\Facades\Gate;

public function boot(): void
{
    Gate::define('viewWatchtower', function ($user) {
        return $user !== null && $user->isAdmin();
    });
}

use Watchtower\Watchtower;

public function boot(): void
{
    Watchtower::auth(fn ($request) => $request->user()?->isAdmin());
}

$schedule->command('watchtower:monitor')->everyFiveMinutes();