PHP code example of exitprobe / laravel

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

    

exitprobe / laravel example snippets


use ExitProbe\Laravel\Facades\ExitProbe;

// List monitors that are currently down
$monitors = ExitProbe::monitors()->list(['status' => 'down']);

// Create a project, then a monitor inside it
$project = ExitProbe::projects()->create(['name' => 'Production']);
$created = ExitProbe::monitors()->createForProject($project['data']['project']['id'], [
    'name' => 'EU Exit Node',
    'expected_exit_ip' => '203.0.113.45',
    'wireguard_enabled' => true,
    'wireguard_config' => "[Interface]\nPrivateKey=...",
]);

// Trigger an on-demand check, then poll it
$dispatched = ExitProbe::monitors()->checkNow($created['data']['monitor']['id']);
ExitProbe::monitors()->checkStatus($created['data']['monitor']['id'], $dispatched['data']['check_ids']);

// Uptime history and full analytics
ExitProbe::monitors()->uptime($created['data']['monitor']['id'], ['range' => '7d']);
ExitProbe::monitors()->analytics($created['data']['monitor']['id'], ['range' => '30d']);

use ExitProbe\Laravel\ExitProbeException;

try {
    ExitProbe::monitors()->create(['name' => '']);
} catch (ExitProbeException $e) {
    report($e);
    // $e->status, $e->errors, $e->getMessage()
}

return [
    'api_key' => env('EXITPROBE_API_KEY'),
    'base_url' => env('EXITPROBE_BASE_URL', 'https://app.exitprobe.com/api/v1'),
    'timeout' => env('EXITPROBE_TIMEOUT', 30),
];
bash
php artisan vendor:publish --tag=exitprobe-config