1. Go to this page and download the library: Download konekt/opsgenie-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/ */
konekt / opsgenie-laravel example snippets
// config/services.php
...
'opsgenie' => [
'auth_token' => env('OPSGENIE_AUTH_TOKEN'),
'europe' => true, // OPTIONAL: if true, then the EU API endpoint will be used
// 'endpoint' => 'https://some.custom.endpoint/', // VERY OPTIONAL: in case you use a non-official endpoint
],
...
use Konekt\OpsGenie\Client\OpsGenieClient;
use Konekt\OpsGenie\Commands\CreateAlert;
$genie = app(OpsGenieClient::class);
$genie->execute(CreateAlert::withMessage('I am an alert message'));
use Konekt\OpsGenie\Client\OpsGenieClient;
use Konekt\OpsGenie\Commands\PingHeartbeat;
$genie = app(OpsGenieClient::class);
$genie->execute(new PingHeartbeat('name of the heartbeat'));
use Illuminate\Notifications\Notification;
use Konekt\OpsGenie\Commands\CreateAlert;
use Konekt\OpsGenie\Contracts\OpsGenieCommand;
use Konekt\OpsGenie\Contracts\OpsGenieNotification;
use Konekt\OpsGenie\Notification\OpsGenieChannel;
class SiteProblem extends Notification implements OpsGenieNotification
{
private string $message;
public function __construct(string $message)
{
$this->message = $message;
}
public function via($notifiable)
{
return [OpsGenieChannel::class];
}
public function toOpsGenie($notifiable): OpsGenieCommand
{
return CreateAlert::withMessage($this->message);
}
}
Notification::send(['*'], new SiteProblem('Hey, there is a problem here'));
use Illuminate\Notifications\Notification;
use Konekt\OpsGenie\Commands\PingHeartbeat;
use Konekt\OpsGenie\Contracts\OpsGenieCommand;
use Konekt\OpsGenie\Contracts\OpsGenieNotification;
use Konekt\OpsGenie\Notification\OpsGenieChannel;
class ERPSyncCompleted extends Notification implements OpsGenieNotification
{
private string $heartbeat;
public function __construct(string $heartbeat)
{
$this->heartbeat = $heartbeat;
}
public function via($notifiable)
{
return [OpsGenieChannel::class];
}
public function toOpsGenie($notifiable): OpsGenieCommand
{
return new PingHeartbeat($this->heartbeat);
}
}
Notification::send(['*'], new ERPSyncCompleted('erp-sync-heartbeat'));
class CriticalConditionDetected extends Notification implements OpsGenieNotification
{
private string $message;
public function __construct(string $message)
{
$this->message = $message;
}
public function via($notifiable)
{
return [OpsGenieChannel::class];
}
public function toOpsGenie($notifiable): OpsGenieCommand
{
$alert = new Alert('Shit hit the fan', ['priority' => 'P1']);
return new CreateAlert($alert);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.