$npx -y skills add getsentry/sentry-for-ai --skill sentry-php-sdkFull Sentry SDK setup for PHP. Use when asked to "add Sentry to PHP", "install sentry/sentry", "setup Sentry in PHP", or configure error monitoring, tracing, profiling, logging, metrics, crons, or AI monitoring for PHP applications. Supports plain PHP, Laravel, and Symfony.
| 1 | > [All Skills](../../SKILL_TREE.md) > [SDK Setup](../sentry-sdk-setup/SKILL.md) > PHP SDK |
| 2 | |
| 3 | # Sentry PHP SDK |
| 4 | |
| 5 | Opinionated wizard that scans your PHP project and guides you through complete Sentry setup. |
| 6 | |
| 7 | ## Invoke This Skill When |
| 8 | |
| 9 | - User asks to "add Sentry to PHP" or "setup Sentry" in a PHP app |
| 10 | - User wants error monitoring, tracing, profiling, logging, metrics, or crons in PHP |
| 11 | - User mentions `sentry/sentry`, `sentry/sentry-laravel`, `sentry/sentry-symfony`, or Sentry + any PHP framework |
| 12 | - User wants to monitor Laravel routes, Symfony controllers, queues, scheduled tasks, or plain PHP scripts |
| 13 | |
| 14 | > **Note:** SDK versions and APIs below reflect Sentry docs at time of writing (sentry/sentry 4.x, sentry/sentry-laravel 4.x, sentry/sentry-symfony 5.x). |
| 15 | > Always verify against [docs.sentry.io/platforms/php/](https://docs.sentry.io/platforms/php/) before implementing. |
| 16 | |
| 17 | --- |
| 18 | |
| 19 | ## Phase 1: Detect |
| 20 | |
| 21 | Run these commands to understand the project before making recommendations: |
| 22 | |
| 23 | ```bash |
| 24 | # Check existing Sentry |
| 25 | grep -i sentry composer.json composer.lock 2>/dev/null |
| 26 | |
| 27 | # Detect framework |
| 28 | cat composer.json | grep -E '"laravel/framework"|"symfony/framework-bundle"|"illuminate/' |
| 29 | |
| 30 | # Confirm framework via filesystem markers |
| 31 | ls artisan 2>/dev/null && echo "Laravel detected" |
| 32 | ls bin/console 2>/dev/null && echo "Symfony detected" |
| 33 | |
| 34 | # Detect queue systems |
| 35 | grep -E '"laravel/horizon"|"symfony/messenger"' composer.json 2>/dev/null |
| 36 | |
| 37 | # Detect AI libraries |
| 38 | grep -E '"(laravel/ai|openai-php|openai/|anthropic|llm)' composer.json 2>/dev/null |
| 39 | |
| 40 | # Check for companion frontend |
| 41 | ls frontend/ resources/js/ assets/ 2>/dev/null |
| 42 | cat package.json 2>/dev/null | grep -E '"react"|"svelte"|"vue"|"next"' |
| 43 | ``` |
| 44 | |
| 45 | **What to note:** |
| 46 | - Is `sentry/sentry` (or `-laravel` / `-symfony`) already in `composer.json`? If yes, check if the init call exists — may just need feature config. |
| 47 | - Framework detected? **Laravel** (has `artisan` + `laravel/framework` in composer.json), **Symfony** (has `bin/console` + `symfony/framework-bundle`), or **plain PHP**. |
| 48 | - Queue system? (Laravel Queue / Horizon, Symfony Messenger need queue worker configuration.) |
| 49 | - AI libraries? (`laravel/ai` is auto-instrumented by `sentry/sentry-laravel >= 4.27.0` when tracing is enabled; other PHP AI libraries need manual spans.) |
| 50 | - Companion frontend? (Triggers Phase 4 cross-link.) |
| 51 | |
| 52 | --- |
| 53 | |
| 54 | ## Phase 2: Recommend |
| 55 | |
| 56 | Based on what you found, present a concrete proposal. Don't ask open-ended questions — lead with a recommendation: |
| 57 | |
| 58 | **Always recommended (core coverage):** |
| 59 | - ✅ **Error Monitoring** — captures unhandled exceptions and PHP errors |
| 60 | - ✅ **Logging** — Monolog integration (Laravel/Symfony auto-configure; plain PHP uses `MonologHandler`) |
| 61 | |
| 62 | **Recommend when detected:** |
| 63 | - ✅ **Tracing** — web framework detected (Laravel/Symfony auto-instrument HTTP, DB, Twig/Blade, cache) |
| 64 | - ⚡ **Profiling** — production apps where performance matters (requires `excimer` PHP extension, Linux/macOS only) |
| 65 | - ⚡ **Crons** — scheduler patterns detected (Laravel Scheduler, Symfony Scheduler, custom cron jobs) |
| 66 | - ⚡ **Metrics** — business KPIs or SLO tracking (uses `TraceMetrics` API) |
| 67 | - ✅ **AI Monitoring** — `laravel/ai` detected in a Laravel app (auto-instrumented in `sentry/sentry-laravel >= 4.27.0`) |
| 68 | |
| 69 | **Recommendation matrix:** |
| 70 | |
| 71 | | Feature | Recommend when... | Reference | |
| 72 | |---------|------------------|-----------| |
| 73 | | Error Monitoring | **Always** — non-negotiable baseline | `${SKILL_ROOT}/references/error-monitoring.md` | |
| 74 | | Tracing | Laravel/Symfony detected, or manual spans needed | `${SKILL_ROOT}/references/tracing.md` | |
| 75 | | Profiling | Production + `excimer` extension available | `${SKILL_ROOT}/references/profiling.md` | |
| 76 | | Logging | **Always**; Monolog for Laravel/Symfony | `${SKILL_ROOT}/references/logging.md` | |
| 77 | | Metrics | Business events or SLO tracking needed | `${SKILL_ROOT}/references/metrics.md` | |
| 78 | | Crons | Scheduler or cron patterns detected | `${SKILL_ROOT}/references/crons.md` | |
| 79 | | AI Monitoring | `laravel/ai` detected in a Laravel app, or manual PHP AI spans needed | `${SKILL_ROOT}/references/ai-monitoring.md` | |
| 80 | |
| 81 | Propose: *"I recommend Error Monitoring + Tracing [+ Logging]. Want Profiling, Crons, Metrics, or AI Monitoring too?"* |
| 82 | |
| 83 | --- |
| 84 | |
| 85 | ## Phase 3: Guide |
| 86 | |
| 87 | ### Install |
| 88 | |
| 89 | ```bash |
| 90 | # Plain PHP |
| 91 | composer require sentry/sentry "^4.0" |
| 92 | |
| 93 | # Laravel |
| 94 | composer require sentry/sentry-laravel "^4.0" |
| 95 | |
| 96 | # Laravel with Laravel AI monitoring |
| 97 | composer require sentry/sentry-laravel "^4.27.0" |
| 98 | |
| 99 | # Symfony |
| 100 | composer require sentry/sentry-symfony "^5.0" |
| 101 | ``` |
| 102 | |
| 103 | **System requirements:** |
| 104 | - PHP 7.2 or later |
| 105 | - Extensions: `ext-json`, `ext-mbstring`, `ext-curl` (all re |