Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Ohdear Php Sdk Laravel Package

ohdearapp/ohdear-php-sdk

Official PHP SDK for the Oh Dear API (built on Saloon v4). Authenticate with an API token, manage monitors, fetch user info, and more with typed DTOs and iterators. Configurable timeouts and clear exceptions for validation and API errors.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Microservices/API-First Fit: The SDK is ideal for Laravel/PHP applications requiring Oh Dear API integration (e.g., uptime monitoring, status pages, or incident management). It abstracts HTTP logic via Saloon, a robust HTTP client library, making it a clean fit for API-driven workflows (e.g., cron jobs, CLI tools, or background tasks).
  • Domain-Specific Abstraction: The SDK encapsulates Oh Dear’s monitors, checks, status pages, and maintenance windows into DTOs (Data Transfer Objects) and enums, reducing boilerplate for common operations (e.g., CheckResult::isDown()).
  • Event-Driven Potential: While the SDK itself is synchronous, it could be extended to emit events (e.g., via Laravel’s events system) when monitor states change (e.g., MonitorDown, CertificateExpiring), enabling reactive workflows.

Integration Feasibility

  • Laravel Compatibility:
    • Service Provider: The SDK can be bootstrapped as a Laravel service provider to bind the OhDear client to the container, enabling dependency injection.
    • Facade Pattern: A facade (e.g., OhDear::monitors()) could simplify usage in Blade templates or controllers.
    • Queue Jobs: Async operations (e.g., requestCheckRun()) can be wrapped in Laravel queues to avoid blocking requests.
  • Database Sync: The SDK’s DTOs can be serialized to JSON or mapped to Eloquent models for local caching (e.g., storing monitor states in a monitors table).
  • Testing: Saloon’s built-in mocking and test helpers align well with Laravel’s testing tools (e.g., Http::fake()).

Technical Risk

Risk Area Mitigation Strategy
API Rate Limits Implement exponential backoff in retries and monitor API usage via Oh Dear’s rate limit docs.
Token Management Store API tokens in Laravel’s env() or Vault (e.g., Hashicorp Vault). Rotate tokens via Oh Dear’s API.
Schema Changes Use Saloon’s schema validation to catch API contract mismatches early. Monitor Oh Dear’s changelog for breaking changes.
Performance For high-frequency checks (e.g., every minute), cache responses (e.g., Redis) or use Oh Dear’s webhooks instead.
Error Handling Extend Saloon’s exceptions to log structured errors (e.g., Sentry) and implement circuit breakers for transient failures.

Key Questions

  1. Use Case Priority:
    • Will the SDK be used for real-time monitoring (e.g., dashboard updates) or batch processing (e.g., nightly reports)?
    • Are status pages or maintenance windows the primary focus, or both?
  2. Data Flow:
    • Should monitor data be synced locally (e.g., for offline analysis) or treated as read-only API data?
    • Will the app trigger actions based on Oh Dear’s data (e.g., Slack alerts, auto-scaling)?
  3. Authentication:
    • Will multiple API tokens be used (e.g., per team)? If so, how will they be managed?
  4. Extensibility:
    • Are there plans to extend the SDK (e.g., add custom checks or webhook listeners)?
    • Should the SDK be wrapped in a Laravel package for internal reuse?
  5. Compliance:
    • Does Oh Dear’s API usage align with data residency or GDPR requirements?

Integration Approach

Stack Fit

  • Laravel Core:
    • Service Container: Register the SDK as a singleton binding:
      $this->app->singleton(OhDear::class, function ($app) {
          return new OhDear(config('services.ohdear.token'));
      });
      
    • Config: Store API token and timeout in config/services/ohdear.php:
      'token' => env('OHDEAR_API_TOKEN'),
      'timeout' => env('OHDEAR_TIMEOUT', 10),
      
  • Queue System:
    • Wrap SDK calls in Laravel Jobs for async operations (e.g., CreateMonitorJob).
    • Example:
      OhDear::dispatchSync(new CreateMonitorJob($monitorData));
      
  • Event System:
    • Publish events for monitor state changes (e.g., MonitorStatusUpdated).
    • Example listener:
      public function handle(MonitorStatusUpdated $event) {
          if ($event->monitor->isDown()) {
              Alert::send('slack', $event->monitor->url);
          }
      }
      
  • Testing:
    • Use Saloon’s mocking in PHPUnit:
      Saloon::shouldReceive('get')
          ->with('monitors')
          ->andReturn(new OhDearResponse([...]));
      

Migration Path

  1. Phase 1: Core Integration (2–4 weeks):
    • Set up SDK in a Laravel service provider.
    • Implement CRUD for monitors and status pages in a dedicated OhDearService.
    • Add basic error handling (log to Sentry/Monolog).
  2. Phase 2: Async & Caching (1–2 weeks):
    • Move non-critical operations to queues (e.g., requestCheckRun).
    • Cache monitor data in Redis (TTL: 5 minutes).
  3. Phase 3: Extensions (Ongoing):
    • Build webhook listeners for real-time updates.
    • Create custom commands (e.g., php artisan ohdear:sync-monitors).
    • Add Laravel Notifications for alerts.

Compatibility

  • Laravel Versions: Tested with Laravel 10+ (PHP 8.1+). Saloon v4 requires PHP 8.0+.
  • Oh Dear API: The SDK matches Oh Dear’s 2026-03-30 API version. Monitor for deprecations in future releases.
  • Dependencies:
    • Guzzle HTTP (via Saloon) for HTTP requests.
    • Symfony Contracts (already in Laravel).
    • No conflicts with Laravel’s core packages.

Sequencing

Step Task Dependencies
1 Set up SDK in Laravel Composer, Laravel config
2 Implement monitor CRUD Oh Dear API token
3 Add status page logic Monitor integration
4 Queue async operations Laravel queues
5 Add caching layer Redis
6 Build event listeners Laravel events
7 Add webhook endpoints Oh Dear webhook setup

Operational Impact

Maintenance

  • SDK Updates:
    • Monitor Oh Dear’s changelog and Saloon’s releases for breaking changes.
    • Update dependencies via composer update ohdearapp/ohdear-php-sdk --with-dependencies.
  • Token Rotation:
    • Implement a cron job to refresh tokens before expiration (Oh Dear tokens expire after 1 year).
    • Example:
      $ohDear->rotateToken(oldToken: 'abc123', newToken: 'def456');
      
  • Schema Validation:
    • Use Saloon’s request validation to fail fast on API changes:
      $request = new CreateMonitorRequest(['url' => 'invalid']);
      $response = $ohDear->send($request); // Throws ValidationException
      

Support

  • Debugging:
    • Enable Saloon’s debug mode for API logs:
      $ohDear = new OhDear(token: '...', debug: true);
      
    • Use Laravel’s debugbar to inspect Oh Dear responses.
  • Common Issues:
    • Rate Limits: Implement retry logic with jitter.
    • Timeouts: Adjust timeoutInSeconds for slow endpoints.
    • CORS: Ensure Oh Dear’s API is whitelisted in your firewall.

Scaling

  • Horizontal Scaling:
    • The SDK is stateless (except for cached data), so it scales horizontally with Laravel’s queue workers.
    • For high-volume checks, use Oh Dear’s webhooks instead of polling.
  • Performance Bottlenecks:
    • Batch API Calls: Use Oh Dear’s pagination (e.g., monitors?page=2) for large datasets.
    • Parallel Requests: Saloon supports parallel requests for independent operations (e.g
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4