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

Laravel Ohdear Webhooks Laravel Package

ohdearapp/laravel-ohdear-webhooks

Laravel package to receive and handle Oh Dear webhooks in your app. Includes ready-made routes, signature validation, and an easy way to map webhook events to jobs or listeners so you can react to uptime, broken links, and other monitor events.

Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Event-Driven Alignment: The package leverages Laravel’s built-in event system, making it a natural fit for applications already using events (e.g., Queue, Broadcasting, or Notifications). It aligns well with microservices or modular architectures where webhook handling is decoupled from core business logic.
  • Middleware Integration: The package’s webhook verification and payload parsing can be cleanly integrated into Laravel’s middleware stack (e.g., VerifyOhDearWebhook), reducing boilerplate in route definitions.
  • Domain-Specific Use Case: Ideal for Laravel apps monitoring external services (e.g., uptime, SSL, or security alerts) where Oh Dear’s webhooks provide real-time notifications. Less relevant for apps without external monitoring dependencies.

Integration Feasibility

  • Low-Coupling Design: The package injects minimal dependencies (e.g., OhDearWebhook service, OhDearWebhookEvent listeners), allowing for easy extraction if needs change.
  • Laravel Ecosystem Synergy: Works seamlessly with:
    • Queues: Async processing of webhook payloads (e.g., dispatch(new OhDearWebhookEvent($payload))).
    • Notifications: Trigger email/SMS alerts via Laravel’s notification system.
    • Logging: Integrates with Monolog for audit trails.
  • Configuration Over Convention: Supports .env for webhook secret validation, reducing hardcoded dependencies.

Technical Risk

  • Secret Management: Misconfiguration of OHDEAR_WEBHOOK_SECRET could expose endpoints to spoofing. Risk mitigated by Laravel’s built-in hash_hmac validation.
  • Payload Schema Changes: Oh Dear may update webhook payload structures. Risk: Package lacks explicit versioning for payload schemas. Mitigation: Implement a payload_schema_validator trait or middleware to enforce expected fields.
  • Idempotency: No built-in deduplication for retried webhooks. Risk of duplicate processing. Mitigation: Add a webhook_attempts table or use Laravel’s unique() rule in a webhook_log table.
  • Performance: High-frequency webhooks could overwhelm queues. Mitigation: Use Laravel’s afterCommit hooks or batch processing for critical paths.

Key Questions

  1. Event Handling Strategy:
    • Should webhook events trigger synchronous actions (e.g., immediate alerts) or async workflows (e.g., queued jobs)?
    • How will conflicts be resolved if the same webhook is retried multiple times?
  2. Monitoring:
    • Are there existing dashboards (e.g., Laravel Horizon, Grafana) to track webhook delivery success/failure?
  3. Testing:
    • How will webhook payloads be mocked in unit/integration tests? (Suggest using mockswebhooks.com or Laravel’s HttpTests.)
  4. Scaling:
    • Will the app need to handle webhooks across multiple Laravel instances (e.g., in a load-balanced setup)? If so, how will duplicate processing be prevented?
  5. Custom Logic:
    • Are there Oh Dear-specific payload fields requiring custom business logic (e.g., parsing incident_type)?

Integration Approach

Stack Fit

  • Core Stack: Optimized for Laravel 10+ (PHP 8.1+). Compatible with:
    • Queues: Database, Redis, or SQS for async processing.
    • Broadcasting: Pusher, Laravel Echo, or WebSockets for real-time alerts.
    • Testing: PestPHP or PHPUnit for webhook scenario testing.
  • Non-Laravel Considerations:
    • If using non-Laravel PHP (e.g., Symfony), the package’s event-driven approach may require adaptation (e.g., wrapping in a Symfony EventDispatcher).
    • For non-PHP stacks, consider Oh Dear’s native API instead of webhooks.

Migration Path

  1. Discovery Phase:
    • Audit existing webhook handlers (if any) for Oh Dear or similar services.
    • Identify gaps (e.g., missing alert escalation, manual parsing of payloads).
  2. Proof of Concept:
    • Set up a webhooks.test route with the package’s VerifyOhDearWebhook middleware.
    • Test with Oh Dear’s sandbox webhook endpoint (https://webhook.test).
    • Validate payload parsing using OhDearWebhook::parse($request).
  3. Incremental Rollout:
    • Phase 1: Replace manual webhook logic with the package’s OhDearWebhookEvent.
    • Phase 2: Integrate with queues/notifications (e.g., OhDearWebhookEvent::dispatch()->onQueue('webhooks')).
    • Phase 3: Add custom listeners for business logic (e.g., handleSslExpiry()).
  4. Deprecation:
    • Phase out legacy webhook handlers post-migration.

Compatibility

  • Laravel Versions: Tested on Laravel 10+. For older versions (e.g., 9.x), check for breaking changes in Illuminate\Support\Facades\Event.
  • PHP Extensions: Requires openssl for HMAC validation (enabled by default in Laravel).
  • Oh Dear API: Ensure the package’s expected payload schema matches Oh Dear’s current webhook format (check Oh Dear’s docs for updates).
  • Third-Party Conflicts: No known conflicts with popular Laravel packages (e.g., Spatie’s laravel-webhook-client), but test with composer why-not ohdearapp/laravel-ohdear-webhooks.

Sequencing

  1. Prerequisites:
    • Configure Oh Dear to send webhooks to your Laravel app’s /webhooks/ohdear endpoint.
    • Set OHDEAR_WEBHOOK_SECRET in .env (matching Oh Dear’s configured secret).
  2. Core Integration:
    • Add middleware to app/Http/Kernel.php:
      'webhook' => \OhDearApp\LaravelOhDearWebhooks\Middleware\VerifyOhDearWebhook::class,
      
    • Define route:
      Route::post('/webhooks/ohdear', [OhDearWebhookController::class, 'handle']);
      
  3. Event Listeners:
    • Register listeners in EventServiceProvider:
      protected $listen = [
          OhDearWebhookEvent::class => [
              HandleSslAlerts::class,
              QueueWebhookForReview::class,
          ],
      ];
      
  4. Testing:
    • Write feature tests for:
      • Webhook signature validation.
      • Payload parsing (e.g., assertEquals('ssl_expiry', $event->incident_type)).
      • Queue job dispatching.

Operational Impact

Maintenance

  • Package Updates:
    • Monitor ohdearapp/laravel-ohdear-webhooks for releases (MIT license allows forks if needed).
    • Update dependencies via composer update ohdearapp/laravel-ohdear-webhooks.
  • Custom Logic:
    • High likelihood of extending the package with custom listeners (e.g., for Slack alerts). Document these in a WEBHOOK_HANDLERS.md.
  • Deprecation:
    • If Oh Dear sunsets webhooks, the package can be replaced with their API client or a generic webhook handler.

Support

  • Troubleshooting:
    • Common issues:
      • Signature Mismatch: Verify OHDEAR_WEBHOOK_SECRET in .env.
      • Payload Parsing Errors: Check Oh Dear’s webhook schema for changes.
      • Queue Failures: Monitor failed_jobs table for exceptions.
    • Debugging tools:
      • Laravel’s dd($event) in listeners.
      • Oh Dear’s webhook test mode (if available).
  • Documentation:
    • Add internal runbook for:
      • Reconfiguring webhook secrets.
      • Handling false positives (e.g., test alerts).
      • Escalation paths for critical incidents (e.g., incident_type = "outage").

Scaling

  • Horizontal Scaling:
    • Stateless Handling: The package is stateless; multiple Laravel instances can process webhooks independently.
    • Idempotency: Implement a webhook_log table with unique(webhook_id, signature) to prevent duplicates.
  • Performance:
    • Queue Throttling: Use Laravel’s afterCommit or retryAfter to limit webhook processing rate.
    • Payload Size: Oh Dear’s payloads are typically small (<1KB), but validate with json_decode($payload, true) for large responses.
  • Cost:
    • Async processing (queues) may increase cloud costs (e.g., AWS SQS, Redis). Monitor with Laravel Horizon.

Failure Modes

Failure Scenario Impact Mitigation
Webhook secret leakage Unauthorized spoofing Rotate secrets via Oh Dear dashboard; use Laravel’s env() caching cautiously.
Queue worker crashes Missed alerts Implement dead-letter queues; use retryAfter delays.
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
milesj/emojibase
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