ohdearapp/ohdear-php-sdk
Official PHP SDK for the Oh Dear monitoring API. Built on Saloon v4, it provides typed DTOs and convenient methods to manage monitors and more. Supports API token auth, configurable timeouts, and clear exceptions for validation and API errors.
OhDearServiceProvider binding OhDear to the container).php artisan ohdear:create-monitor).Schedule::call() to poll monitor statuses).OhDearException → report()).CheckType) are used. Ensure your Laravel version supports these.Mockery or HTTP clients like GuzzleHttp/HandlerStack.config? Vault?)Monitor::belongsTo(User))?monitor_statuses table) for faster queries?$this->app->singleton(OhDear::class, function ($app) {
return new OhDear(config('services.ohdear.token'));
});
config/services.php:
'ohdear' => [
'token' => env('OHDEAR_API_TOKEN'),
'timeout' => env('OHDEAR_TIMEOUT', 10),
'webhook_secret' => env('OHDEAR_WEBHOOK_SECRET'),
],
$ohDear = new OhDear($token, [
'http_client' => Http::withOptions(['timeout' => 30]),
]);
/api/ohdear/webhook). Validate payloads with OHDEAR_WEBHOOK_SECRET.createMonitor, checkSummary) in a local Laravel app.app/Services/OhDearService) to abstract API calls.Monolog) and monitoring (e.g., laravel-debugbar).env(), Laravel’s config, or a secrets manager).AppServiceProvider.Monitor, CheckSummary) in Laravel’s context.ohdearapp/ohdear-php-sdk repo for updates. Use Composer’s minimum-stability to avoid pre-release risks.composer.json to avoid transitive updates.OhDear::createMonitor()) with:
Log::debug('Oh Dear monitor created', [
'monitor' => $monitor->toArray(),
'duration_ms' => $stopwatch->duration(),
]);
OhDearException and log/notify:
public function render($request, Throwable $exception) {
if ($exception instanceof OhDearException) {
report($exception);
return response()->json(['error' => 'Oh Dear API failed'], 502);
}
return parent::render($request, $exception);
}
429 Too Many Requests).Route::middleware(['throttle:ohdear,60'])->group(function () {
// Oh Dear API routes
});
How can I help you explore Laravel packages today?