
Sentry Php Sdk
Instrument PHP and Laravel cron jobs with Sentry Crons check-ins so missed or failed scheduled tasks surface in production monitoring.
Overview
sentry-php-sdk is an agent skill for the Operate phase that wires PHP and Laravel cron jobs to Sentry Crons via check-ins and optional heartbeats.
Install
npx skills add https://github.com/getsentry/sentry-for-ai --skill sentry-php-sdkWhat is this skill?
- Three integration paths: withMonitor() wrapper, manual captureCheckIn(), and Laravel sentryMonitor() macro
- Documents minimum SDK floors: sentry/sentry ≥ 3.16.0 and sentry/sentry-laravel ≥ 3.3.1
- Manual flow covers IN_PROGRESS, OK, and ERROR with shared checkInId for paired check-ins
- Heartbeat mode for missed-start detection when jobs never fire on schedule
- Exception path rethrows after ERROR check-in so failures stay visible in both Sentry and app logs
- Minimum sentry/sentry SDK version 3.16.0
- Minimum sentry/sentry-laravel version 3.3.1
- Three documented integration approaches
Adoption & trust: 1.1k installs on skills.sh; 197 GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
What problem does it solve?
You run PHP cron or Laravel scheduled tasks but only learn they failed when users complain or data goes stale.
Who is it for?
PHP or Laravel apps already using Sentry that need first-class visibility into cron and scheduler reliability.
Skip if: Teams not on Sentry PHP SDK ≥ 3.16.0 (or Laravel package ≥ 3.3.1), or one-off scripts where you will not register a stable monitor slug in Sentry.
When should I use this skill?
Adding or debugging Sentry Crons for PHP/Laravel scheduled jobs, choosing wrapper vs manual check-ins, or configuring heartbeat monitors.
What do I get? / Deliverables
Scheduled jobs emit structured Sentry Crons check-ins on start, success, and failure so missed runs and errors appear in your monitoring dashboard.
- Instrumented cron or scheduler code with check-in flow
- Monitor slug configuration aligned with Sentry Crons
- Error path that records ERROR check-in before rethrow
Recommended Skills
Journey fit
Cron reliability is an ongoing production concern after launch—canonical shelf is Operate because the skill wires live scheduled jobs to observability, not greenfield build. Subphase monitoring matches Sentry Crons’ purpose: track job start, success, failure, and heartbeats against expected schedules.
How it compares
Operational cron monitor wiring for Sentry—not a generic error-reporting or APM setup guide.
Common Questions / FAQ
Who is sentry-php-sdk for?
Solo and indie builders maintaining PHP or Laravel apps who use Sentry and need Crons coverage for scheduled jobs without writing custom uptime polling.
When should I use sentry-php-sdk?
Use it in Operate when you deploy or harden schedulers—instrument new crons before launch prep, validate check-ins after ship, and add heartbeats when silent missed runs are the main risk.
Is sentry-php-sdk safe to install?
Review the Security Audits panel on this Prism page and your org’s policy before pulling the skill; it documents network calls to Sentry and code you will embed in production job paths.
SKILL.md
READMESKILL.md - Sentry Php Sdk
# Crons — Sentry PHP SDK > Minimum SDK versions: `sentry/sentry` ≥ 3.16.0 · `sentry/sentry-laravel` ≥ 3.3.1 ## Overview Sentry Crons monitors scheduled jobs by receiving check-ins at job start, success, and failure. Three approaches: | Approach | Use when | |----------|---------| | `withMonitor()` wrapper | Simple wrapping of any callable | | `captureCheckIn()` manually | Need control over timing, status, or heartbeats | | `sentryMonitor()` macro (Laravel) | Laravel scheduled tasks — minimal boilerplate | ## Code Examples ### `withMonitor()` wrapper (simplest) ```php \Sentry\withMonitor( slug: 'my-cron-job', callback: fn() => doSomething(), ); // Sends IN_PROGRESS before, OK on success, ERROR on exception ``` ### Manual check-ins with `captureCheckIn()` ```php use Sentry\CheckInStatus; // 1. Signal job started $checkInId = \Sentry\captureCheckIn( slug: 'my-cron-job', status: CheckInStatus::inProgress(), ); try { // 2. Do work runScheduledTask(); // 3a. Signal success \Sentry\captureCheckIn( slug: 'my-cron-job', status: CheckInStatus::ok(), checkInId: $checkInId, ); } catch (\Throwable $e) { // 3b. Signal failure \Sentry\captureCheckIn( slug: 'my-cron-job', status: CheckInStatus::error(), checkInId: $checkInId, ); throw $e; } ``` ### Heartbeat (single check-in) Only notifies if the job **didn't start** when expected (missed). Does not detect max runtime exceeded. ```php // Success \Sentry\captureCheckIn( slug: 'my-cron-job', status: CheckInStatus::ok(), duration: 10, // optional: seconds ); // Failure \Sentry\captureCheckIn( slug: 'my-cron-job', status: CheckInStatus::error(), ); ``` ### Upsert monitor config programmatically Define monitor settings in code so Sentry creates/updates the monitor automatically on first check-in: ```php use Sentry\CheckInStatus; use Sentry\MonitorConfig; use Sentry\MonitorSchedule; use Sentry\MonitorScheduleUnit; // Crontab schedule $monitorConfig = new MonitorConfig( MonitorSchedule::crontab('0 2 * * *'), // every day at 2 AM checkinMargin: 5, // minutes late before MISSED alert maxRuntime: 15, // minutes before TIMEOUT alert timezone: 'Europe/Vienna', failureIssueThreshold: 2, // consecutive failures before issue recoveryThreshold: 5, // consecutive successes to resolve ); $checkInId = \Sentry\captureCheckIn( slug: 'daily-backup', status: CheckInStatus::inProgress(), monitorConfig: $monitorConfig, ); runBackup(); \Sentry\captureCheckIn( slug: 'daily-backup', status: CheckInStatus::ok(), checkInId: $checkInId, ); ``` ```php // Interval schedule $monitorConfig = new MonitorConfig( MonitorSchedule::interval(10, MonitorScheduleUnit::minute()), checkinMargin: 5, maxRuntime: 8, ); ``` ### Laravel — `sentryMonitor()` macro Add `sentryMonitor()` to any scheduled task in `routes/console.php`: ```php use Illuminate\Support\Facades\Schedule; Schedule::command(SendEmailsCommand::class) ->everyHour() ->sentryMonitor(); // that's it ``` With full configuration: ```php Schedule::command(SendEmailsCommand::class) ->everyHour() ->sentryMonitor( monitorSlug: null, // auto-generated if null checkInMargin: 5, // minutes before MISSED alert maxRuntime: 15, // minutes before TIMEOUT alert failureIssueThreshold: 1, // consecutive failures before issue recoveryThreshold: 1, // consecutive successes to resolve updateMonitorConfig: true, // set false to manage config in UI only ); ``` > **Limitation:** Tasks using `between`, `unlessBetween`, `when`, or `skip` are not supported. Use Laravel's `cron()` method for schedule frequency in those cases. ### Symfony — same as base PHP SDK The Symfony bundle has no de