PHP code example of zumba / deadmanssnitch-sdk

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

    

zumba / deadmanssnitch-sdk example snippets




use Zumba\Deadmanssnitch\Notifier;

$notifier = new Notifier();
$notifier->pingSnitch('snitch id', 'just checking in.');



use Zumba\Deadmanssnitch\Client;
use Zumba\Deadmanssnitch\Snitch;
use Zumba\Deadmanssnitch\Interval;
use Zumba\Deadmanssnitch\ResponseError;

$client = new Client('your api key here');

// creating a snitch
$snitch = new Snitch('My cool process', new Interval(Interval::I_DAILY), [
    'tags' => ['production', 'critical']
]);
try {
    $client->createSnitch($snitch);
} catch (ResponseError $e) {
    // Failed to create the snitch
    echo $e->getMessage();
}

echo $snitch;
// 12312412



use Zumba\Deadmanssnitch\Client;
use GuzzleHttp\Client as GuzzleClient;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$http = new GuzzleClient([
    'base_uri' => Client::HOST,
    'auth' => ['my api key', '']
]);

$logger = new Logger('name');
$logger->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));

$client = new Client('my api key', $http, $logger);