MCPInstall

sentry-php-sdk

Full 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.

Installs
2.2K
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/getsentry/sentry-for-ai --skill sentry-php-sdk
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads sentry-php-sdk automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

All Skills > SDK Setup > PHP SDK

Sentry PHP SDK

Opinionated wizard that scans your PHP project and guides you through complete Sentry setup.

Invoke This Skill When

  • User asks to "add Sentry to PHP" or "setup Sentry" in a PHP app
  • User wants error monitoring, tracing, profiling, logging, metrics, or crons in PHP
  • User mentions sentry/sentry, sentry/sentry-laravel, sentry/sentry-symfony, or Sentry + any PHP framework
  • User wants to monitor Laravel routes, Symfony controllers, queues, scheduled tasks, or plain PHP scripts

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). Always verify against docs.sentry.io/platforms/php/ before implementing.


Phase 1: Detect

Run these commands to understand the project before making recommendations:

# Check existing Sentry
grep -i sentry composer.json composer.lock 2>/dev/null

# Detect framework
cat composer.json | grep -E '"laravel/framework"|"symfony/framework-bundle"|"illuminate/'

# Confirm framework via filesystem markers
ls artisan 2>/dev/null && echo "Laravel detected"
ls bin/console 2>/dev/null && echo "Symfony detected"

# Detect queue systems
grep -E '"laravel/horizon"|"symfony/messenger"' composer.json 2>/dev/null

# Detect AI libraries
grep -E '"(laravel/ai|openai-php|openai/|anthropic|llm)' composer.json 2>/dev/null

# Check for companion frontend
ls frontend/ resources/js/ assets/ 2>/dev/null
cat package.json 2>/dev/null | grep -E '"react"|"svelte"|"vue"|"next"'

What to note:

  • Is sentry/sentry (or -laravel / -symfony) already in composer.json? If yes, check if the init call exists — may just need feature config.
  • Framework detected? Laravel (has artisan + laravel/framework in composer.json), Symfony (has bin/console + symfony/framework-bundle), or plain PHP.
  • Queue system? (Laravel Queue / Horizon, Symfony Messenger need queue worker configuration.)
  • 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.)
  • Companion frontend? (Triggers Phase 4 cross-link.)

Phase 2: Recommend

Based on what you found, present a concrete proposal. Don't ask open-ended questions — lead with a recommendation:

Always recommended (core coverage):

  • ✅ Error Monitoring — captures unhandled exceptions and PHP errors
  • ✅ Logging — Monolog integration (Laravel/Symfony auto-configure; plain PHP uses MonologHandler)

Recommend when detected:

  • ✅ Tracing — web framework detected (Laravel/Symfony auto-instrument HTTP, DB, Twig/Blade, cache)
  • ⚡ Profiling — production apps where performance matters (requires excimer PHP extension, Linux/macOS only)
  • ⚡ Crons — scheduler patterns detected (Laravel Scheduler, Symfony Scheduler, custom cron jobs)
  • ⚡ Metrics — business KPIs or SLO tracking (uses TraceMetrics API)
  • ✅ AI Monitoring — laravel/ai detected in a Laravel app (auto-instrumented in sentry/sentry-laravel >= 4.27.0)

Recommendation matrix:

FeatureRecommend when...Reference
Error MonitoringAlways — non-negotiable baseline${SKILL_ROOT}/references/error-monitoring.md
TracingLaravel/Symfony detected, or manual spans needed${SKILL_ROOT}/references/tracing.md
ProfilingProduction + excimer extension available${SKILL_ROOT}/references/profiling.md
LoggingAlways; Monolog for Laravel/Symfony${SKILL_ROOT}/references/logging.md
MetricsBusiness events or SLO tracking needed${SKILL_ROOT}/references/metrics.md
CronsScheduler or cron patterns detected${SKILL_ROOT}/references/crons.md
AI Monitoringlaravel/ai detected in a Laravel app, or manual PHP AI spans needed${SKILL_ROOT}/references/ai-monitoring.md

Propose: "I recommend Error Monitoring + Tracing [+ Logging]. Want Profiling, Crons, Metrics, or AI Monitoring too?"


Phase 3: Guide

Install

# Plain PHP
composer require sentry/sentry "^4.0"

# Laravel
composer require sentry/sentry-laravel "^4.0"

# Laravel with Laravel AI monitoring
composer require sentry/sentry-laravel "^4.27.0"

# Symfony
composer require sentry/sentry-symfony "^5.0"

System requirements:

  • PHP 7.2 or later
  • Extensions: ext-json, ext-mbstring, ext-curl (all required)
  • excimer PECL extension (Linux/macOS only — required for profiling)

Framework-Specific Initialization

Plain PHP

Place \Sentry\init() at the top of your entry point (index.php, bootstrap.php, or equivalent), before any application code:

<?php

require_once 'vendor/autoload.php';

\Sentry\init([
    'dsn'                  => $_SERVER['SENTRY_DSN'] ?? '',
    'environment'          => $_SERVER['SENTRY_ENVIRONMENT'] ?? 'production',
    'release'              => $_SERVER['SENTRY_RELEASE'] ?? null,
    'send_default_pii'     => true,
    'traces_sample_rate'   => 1.0,
    'profiles_sample_rate' => 1.0,
    'enable_logs'          => true,
]);

// rest of application...

Laravel

Step 1 — Register exception handler in bootstrap/app.php:

use Sentry\Laravel\Integration;

return Application::configure(basePath: dirname(__DIR__))
    ->withExceptions(function (Exceptions $exceptions) {
        Integration::handles($exceptions);
    })->create();

Step 2 — Publish config and set DSN:

php artisan sentry:publish --dsn=YOUR_DSN

This creates config/sentry.php and adds SENTRY_LARAVEL_DSN to .env.

Step 3 — Configure .env:

SENTRY_LARAVEL_DSN=https://examplePublicKey@o0.ingest.sentry.io/0
SENTRY_TRACES_SAMPLE_RATE=1.0
SENTRY_PROFILES_SAMPLE_RATE=1.0

For full Laravel configuration options, read ${SKILL_ROOT}/references/laravel.md.

Symfony

Step 1 — Register the bundle in config/bundles.php (auto-done by Symfony Flex):

Sentry\SentryBundle\SentryBundle::class => ['all' => true],

Step 2 — Create config/packages/sentry.yaml:

sentry:
    dsn: '%env(SENTRY_DSN)%'
    options:
        environment: '%env(APP_ENV)%'
        release: '%env(SENTRY_RELEASE)%'
        send_default_pii: true
        traces_sample_rate: 1.0
        profiles_sample_rate: 1.0
        enable_logs: true

Step 3 — Set the DSN in .env:

SENTRY_DSN=https://examplePublicKey@o0.ingest.sentry.io/0

For full Symfony configuration options, read ${SKILL_ROOT}/references/symfony.md.

Quick Start — Recommended Init (Plain PHP)

Full init enabling the most features with sensible defaults:

\Sentry\init([
    'dsn'                     => $_SERVER['SENTRY_DSN'] ?? '',
    'environment'             => $_SERVER['SENTRY_ENVIRONMENT'] ?? 'production',
    'release'                 => $_SERVER['SENTRY_RELEASE'] ?? null,
    'send_default_pii'        => true,

    // Tracing (lower to 0.1–0.2 in high-traffic production)
    'traces_sample_rate'      => 1.0,

    // Profiling — requires excimer extension (Linux/macOS only)
    'profiles_sample_rate'    => 1.0,

    // Structured logs (sentry/sentry >=4.12.0)
    'enable_logs'             => true,
]);

For Each Agreed Feature

Walk through features one at a time. Load the reference, follow its steps, verify before moving on:

FeatureReference fileLoad when...
Error Monitoring${SKILL_ROOT}/references/error-monitoring.mdAlways (baseline)
Tracing${SKILL_ROOT}/references/tracing.mdHTTP handlers / distributed tracing
Profiling${SKILL_ROOT}/references/profiling.mdPerformance-sensitive production
Logging${SKILL_ROOT}/references/logging.mdAlways; Monolog for Laravel/Symfony
Metrics${SKILL_ROOT}/references/metrics.mdBusiness KPIs / SLO tracking
Crons${SKILL_ROOT}/references/crons.mdScheduler / cron patterns detected
AI Monitoring${SKILL_ROOT}/references/ai-monitoring.mdlaravel/ai detected in Laravel, or manual PHP AI spans needed

For each feature: Read ${SKILL_ROOT}/references/<feature>.md, follow steps exactly, verify it works.


Configuration Reference

Key \Sentry\init() Options (Plain PHP)

OptionTypeDefaultPurpose
dsnstring|bool|null$_SERVER['SENTRY_DSN']SDK disabled if empty or false
environmentstring|null$_SERVER['SENTRY_ENVIRONMENT']e.g., "staging"
releasestring|null$_SERVER['SENTRY_RELEASE']e.g., "myapp@1.0.0"
send_default_piiboolfalseInclude request headers, cookies, IP
sample_ratefloat1.0Error event sample rate (0.0–1.0)
traces_sample_ratefloat|nullnullTransaction sample rate; null disables tracing
traces_samplercallable|nullnullCustom per-transaction sampling (overrides rate)
profiles_sample_ratefloat|nullnullProfiling rate relative to traces; requires excimer
enable_logsboolfalseSend structured logs to Sentry (>=4.12.0)
max_breadcrumbsint100Max breadcrumbs per event
attach_stacktraceboolfalseStack traces on captureMessage()
in_app_includestring[][]Path prefixes belonging to your app
in_app_excludestring[][]Path prefixes for third-party code (hidden in traces)
ignore_exceptionsstring[][]Exception FQCNs to never report
ignore_transactionsstring[][]Transaction names to never report
error_typesint|nullerror_reporting()PHP error bitmask (e.g., E_ALL & ~E_NOTICE)
capture_silenced_errorsboolfalseCapture errors suppressed by @ operator
max_request_body_sizestring"medium""none" / "small" / "medium" / "always"
before_sendcallableidentityfn(Event $event, ?EventHint $hint): ?Event — return null to drop
before_breadcrumbcallableidentityfn(Breadcrumb $b): ?Breadcrumb — return null to discard
trace_propagation_targetsstring[]|nullnullDownstream hosts to inject sentry-trace headers into; null = all, [] = none
strict_trace_continuationboolfalseOnly continue an incoming distributed trace if the sentry-org_id baggage matches the SDK's org ID; prevents trace contamination from third-party Sentry-instrumented services (>=4.21.0)
debugboolfalseVerbose SDK output (use a PSR-3 logger option instead for structured output)

Environment Variables

VariableMaps toNotes
SENTRY_DSNdsnAlso $_SERVER['SENTRY_DSN']
SENTRY_ENVIRONMENTenvironment
SENTRY_RELEASEreleaseAlso reads $_SERVER['AWS_LAMBDA_FUNCTION_VERSION']
SENTRY_SPOTLIGHTspotlight

Laravel note: Uses SENTRY_LARAVEL_DSN (falls back to SENTRY_DSN). Other options follow SENTRY_TRACES_SAMPLE_RATE, SENTRY_PROFILES_SAMPLE_RATE, etc.


Verification

Test that Sentry is receiving events:

// Trigger a real error event — check the Sentry dashboard within seconds
throw new \Exception('Sentry PHP SDK test');

Or for a non-crashing check:

\Sentry\captureMessage('Sentry PHP SDK test');

Laravel:

php artisan sentry:test

If nothing appears:

  1. Enable debug output:
    \Sentry\init([
        'dsn' => '...',
        'logger' => new \Sentry\Logger\DebugStdOutLogger(),
    ]);
    
  2. Verify the DSN is correct (format: https://<key>@o<org>.ingest.sentry.io/<project>)
  3. Check SENTRY_DSN (or SENTRY_LARAVEL_DSN) env var is set in the running process
  4. For queue workers: ensure Sentry is initialized inside the worker process, not just the web process

Phase 4: Cross-Link

After completing PHP setup, check for a companion frontend missing Sentry:

ls frontend/ resources/js/ assets/ public/ 2>/dev/null
cat package.json frontend/package.json 2>/dev/null \
  | grep -E '"react"|"svelte"|"vue"|"next"|"nuxt"'

If a frontend exists without Sentry, suggest the matching skill:

Frontend detectedSuggest skill
React / Next.jssentry-react-sdk
Svelte / SvelteKitsentry-svelte-sdk
Vue / NuxtUse @sentry/vue — see docs.sentry.io/platforms/javascript/guides/vue/
Other JS/TSsentry-react-sdk (covers generic browser JS patterns)

Troubleshooting

IssueSolution
Events not appearingEnable logger option (DebugStdOutLogger), verify DSN, check env vars in the running process
Malformed DSN errorFormat: https://<key>@o<org>.ingest.sentry.io/<project>
Laravel exceptions not capturedEnsure Integration::handles($exceptions) is in bootstrap/app.php
Symfony exceptions not capturedVerify SentryBundle is registered in config/bundles.php
No traces appearingSet traces_sample_rate (not null); confirm auto-instrumentation is enabled
Profiling not workingexcimer extension required (Linux/macOS only; not available on Windows); requires traces_sample_rate > 0
enable_logs not workingRequires sentry/sentry >= 4.12.0, sentry/sentry-laravel >= 4.15.0, or sentry/sentry-symfony >= 5.4.0
Queue worker errors missingInit Sentry in the worker process itself, not just the web process; for Laravel use SENTRY_LARAVEL_DSN in worker .env
Too many transactionsLower traces_sample_rate or use traces_sampler to drop health check routes
PII not capturedSet send_default_pii: true; for Laravel set send_default_pii: true in config/sentry.php
@-suppressed errors missingSet capture_silenced_errors: true
Cross-service traces brokenCheck trace_propagation_targets; ensure downstream services have Sentry installed
Trace contamination from third-party servicesSet strict_trace_continuation: true to only continue traces where the incoming sentry-org_id baggage matches your SDK's org ID (>=4.21.0)

FAQ

What does the sentry-php-sdk skill do?

Full 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.

How do I install sentry-php-sdk?

Run npx skills add https://github.com/getsentry/sentry-for-ai --skill sentry-php-sdk in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/sentry-php-sdk/ (personal) or .claude/skills/sentry-php-sdk/ (project).

Which AI agents can use sentry-php-sdk?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is sentry-php-sdk safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains sentry-php-sdk?

It is published by getsentry in getsentry/sentry-for-ai, and it is an official skill from the maker of the technology it covers. It has 2,249 recorded installs.

More from getsentry/sentry-for-ai

View all →

sentry-fix-issues

getsentry/sentry-for-ai

Find and fix issues from Sentry using MCP. Use when asked to fix Sentry errors, debug production issues, investigate exceptions, or resolve bugs reported in Sentry. Methodically analyzes stack traces, breadcrumbs, traces, and context to identify root causes.

OfficialDevOps & Cloud10K installs

sentry-react-native-sdk

getsentry/sentry-for-ai

Full Sentry SDK setup for React Native and Expo. Use when asked to "add Sentry to React Native", "install @sentry/react-native", "setup Sentry in Expo", or configure error monitoring, tracing, profiling, session replay, or logging for React Native applications. Supports Expo managed, Expo bare, and vanilla React Native.

OfficialDevOps & Cloud4.1K installs

sentry-create-alert

getsentry/sentry-for-ai

Create Sentry alerts using the workflow engine API. Use when asked to create alerts, set up notifications, configure issue priority alerts, or build workflow automations. Supports email, Slack, PagerDuty, Discord, and other notification actions.

OfficialDevOps & Cloud4.1K installs

sentry-nextjs-sdk

getsentry/sentry-for-ai

Full Sentry SDK setup for Next.js. Use when asked to "add Sentry to Next.js", "install @sentry/nextjs", or configure error monitoring, tracing, session replay, logging, profiling, AI monitoring, or crons for Next.js applications. Supports Next.js 13+ with App Router and Pages Router.

OfficialDevOps & Cloud3.6K installs

sentry-sdk-setup

getsentry/sentry-for-ai

Set up Sentry in any language or framework. Detects the user's platform and loads the right SDK skill. Use when asked to add Sentry, install an SDK, or set up error monitoring in a project.

OfficialDevOps & Cloud3.6K installs

sentry-workflow

getsentry/sentry-for-ai

Keep Sentry SDKs up to date. Use when asked to upgrade the Sentry SDK across major versions, migrate SDK versions, or fix deprecated APIs.

OfficialDevOps & Cloud3.6K installs

Popular devops & cloud skills

View category →

microsoft-foundry

microsoft/azure-skills

Build, deploy, evaluate, optimize, fine-tune, and manage Microsoft Foundry agents, models, and resources end to end. USE FOR: foundry, azd ai agent, azd provision/deploy, hosted agent scaffold/develop/run/deploy/troubleshoot, prompt agent create, managed harness agent create, GitHub Copilot harness agent, create agent, update agent, add tool to agent, invoke agent, agent insights, evaluate agent, batch eval, continuous eval, continuous monitoring, agent CI/CD, optimize prompt, improve prompt, optimize agent instructions, Agent Optimizer scaffold, dataset curation from traces, deploy model, model fine-tuning (SFT/DPO/RFT), Foundry project, RBAC, role assignment, permissions, quota, capacity, region, deployment failure, AI Services, create Foundry resource, knowledge index, customize deployment, onboard, availability, training-data, grader, distillation, large file upload. DO NOT USE FOR: Azure Functions, App Service, general Azure deploy (use azure-deploy), general Azure prep (use azure

OfficialDevOps & Cloud579.1K installs

azure-diagnostics

microsoft/azure-skills

Debug Azure production issues on Azure using AppLens, Azure Monitor, resource health, and safe triage. WHEN: debug production issues, troubleshoot app service, app service high CPU, app service deployment failure, troubleshoot container apps, container app 503 or target port mismatch, troubleshoot functions, function telemetry missing or stopped after a config/connection-string change, troubleshoot AKS, VM RDP, Linux SSH, VM black screen, can't connect to VM, reset VM password, NSG or firewall blocking, kubectl cannot connect, kube-system/CoreDNS failures, pod pending, crashloop, node not ready, upgrade failures, analyze logs, KQL, insights, image pull failures, cold start issues, health probe failures, resource health, root cause of errors, troubleshoot event hubs, troubleshoot service bus, messaging SDK error, AMQP connection failure, message lock lost, lock renewal during long-running processing, service bus dead letter.

OfficialDevOps & Cloud569.8K installs

azure-prepare

microsoft/azure-skills

Prepare azd-based Azure projects for deployment: generates azure.yaml, infrastructure (Bicep/Terraform), and Dockerfiles for the Azure Developer CLI (azd) workflow. USE ONLY when the user explicitly wants to use azd as the deployment tool, or the project already has an azure.yaml file. DO NOT USE FOR: non-azd deployments, Python App Service code-only deploys (use python-appservice-deploy), or cross-cloud migration (use azure-cloud-migrate). WHEN: prepare app for azd, create azure.yaml, set up azd infrastructure, modernize app for Azure with azd, deploy with azd, function app, timer trigger, service bus trigger, event-driven function, managed identity, generate Bicep, generate Terraform, create and deploy to Azure.

OfficialDevOps & Cloud569K installs

azure-ai

microsoft/azure-skills

Use for Azure AI: Search, Speech, OpenAI, Document Intelligence. Helps with search, vector/hybrid search, speech-to-text, text-to-speech, transcription, OCR. WHEN: AI Search, query search, vector search, hybrid search, semantic search, speech-to-text, text-to-speech, transcribe, OCR, convert text to speech.

OfficialDevOps & Cloud568.8K installs

azure-deploy

microsoft/azure-skills

Execute Azure deployments for ALREADY-PREPARED applications that have existing .azure/deployment-plan.md and infrastructure files. DO NOT use this skill when the user asks to CREATE a new application — use azure-prepare instead. This skill runs azd up, azd deploy, terraform apply, and az deployment commands with built-in error recovery. Requires .azure/deployment-plan.md from azure-prepare and validated status from azure-validate. WHEN: "run azd up", "run azd deploy", "execute deployment", "push to production", "push to cloud", "go live", "ship it", "bicep deploy", "terraform apply", "publish to Azure", "launch on Azure". DO NOT USE WHEN: "create and deploy", "build and deploy", "create a new app", "set up infrastructure", "create and deploy to Azure using Terraform" — use azure-prepare for these.

OfficialDevOps & Cloud568.6K installs

azure-validate

microsoft/azure-skills

Pre-deployment validation for Azure readiness. Run deep checks on configuration, infrastructure (Bicep or Terraform), RBAC role assignments, managed identity permissions, and prerequisites before deploying. WHEN: validate my app, check deployment readiness, run preflight checks, verify configuration, check if ready to deploy, validate azure.yaml, validate Bicep, test before deploying, troubleshoot deployment errors, validate Azure Functions, validate function app, validate serverless deployment, verify RBAC roles, check role assignments, review managed identity permissions, what-if analysis, validate Container Apps deployment.

OfficialDevOps & Cloud568K installs