getsentry/sentry-php-sdk

Configuração completa do SDK do Sentry para PHP. Use quando solicitado a "adicionar o Sentry ao PHP", "instalar sentry/sentry", "configurar Sentry no PHP" ou configurar monitoramento de erros, rastreamento, perfilamento, registro, métricas ou tarefas cron em aplicações PHP. Suporta PHP puro, Laravel e Symfony.

O que é sentry-php-sdk?

Este skill automatiza a configuração completa do Sentry SDK em projetos PHP, cobrindo desde PHP puro até frameworks populares como Laravel e Symfony. Ele é ativado por comandos como "adicionar Sentry ao PHP" ou "configurar monitoramento no Sentry" e gerencia a instalação via Composer, a criação do arquivo de configuração com o DSN e a integração de recursos avançados: captura de exceções, rastreamento de desempenho (tracing), profiling, logging estruturado, métricas personalizadas e monitoramento de jobs cron. O skill lida com a detecção automática do framework em uso, aplica as melhores práticas de segurança (como uso de variáveis de ambiente) e gera exemplos de código prontos para produção. Suporta versões atuais do PHP (8.1+) e funciona tanto em ambientes CLI quanto web.

Funciona com~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/getsentry/sentry-for-ai/tree/main/skills/sentry-php-sdk

Installed? Explore more Programação e Desenvolvimento skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

Perguntar na sua IA favorita

Abre um novo chat com esta habilidade de agente já pré-carregada.

Documentação

O que sentry-php-sdk faz?

Configuração completa do SDK do Sentry para PHP. Use quando solicitado a "adicionar o Sentry ao PHP", "instalar sentry/sentry", "configurar Sentry no PHP" ou configurar monitoramento de erros, rastreamento, perfilamento, registro, métricas ou tarefas cron em aplicações PHP. Suporta PHP puro, Laravel e Symfony.

Funcionalidades

  • Captura de erros e exceções — relata automaticamente exceções não tratadas e erros fatais.
  • Rastreamento de desempenho — rastreia transações e spans para identificar gargalos.
  • Perfilamento — amostragem de pilhas de chamadas para análise de performance.
  • Registro estruturado — envia logs com contexto rico para o Sentry.
  • Métricas — emite métricas personalizadas (contadores, distribuições, sets, gauges).
  • Tarefas cron — monitora a execução de tarefas agendadas (Cron Monitoring).

Frameworks suportados

  • PHP puro (qualquer aplicação que use Composer)
  • Laravel (5.x e superior)
  • Symfony (4.x e superior)

Como usar

Certifique-se de que o projeto usa PHP 8.1 ou superior e possui o Composer instalado.

1. Instalação

composer require sentry/sentry

2. Configuração

Crie um arquivo config.php ou adicione ao seu arquivo de inicialização:

<?php

require_once __DIR__ . '/vendor/autoload.php';

\Sentry\init([
    'dsn' => getenv('SENTRY_DSN') ?: 'https://[email protected]/0',
    // Opcional: defina o ambiente e release
    'environment' => getenv('APP_ENV') ?: 'production',
    'release' => '1.0.0',
]);

Use variáveis de ambiente para o DSN. Nunca hardcode o DSN no código.

3. Laravel

Para Laravel, instale o pacote de integração:

composer require sentry/sentry-laravel

Publique a configuração:

php artisan vendor:publish --provider="Sentry\Laravel\ServiceProvider"

Edite o arquivo config/sentry.php conforme necessário.

4. Symfony

Instale o bundle:

composer require sentry/sentry-symfony

Adicione ao config/bundles.php:

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

Configure o DSN no arquivo .env:

SENTRY_DSN=https://[email protected]/0

5. Exemplo de uso

<?php

try {
    // Código que pode lançar uma exceção
    throw new \RuntimeException('Algo deu errado!');
} catch (\Throwable $exception) {
    \Sentry\captureException($exception);
}

// Rastreamento manual
\Sentry\startTransaction(['name' => 'minha-transacao']);
// ... código ...
\Sentry\endTransaction();

Solução de problemas

  • Erro: "Class 'Sentry\Sdk' not found" — certifique-se de que o Composer gerou o autoloader.
  • Nenhum erro aparecendo no Sentry — verifique se o DSN está configurado corretamente e se o ambiente está ativo.
  • Problemas de perfilamento — ative o profiling no DSN ou no arquivo de configuração (exige plano com profiling habilitado).

Notas

  • Sempre use variáveis de ambiente para dados sensíveis (DSN, tokens).
  • O desempenho pode ser ajustado com amostragem (traces_sample_rate).
  • Consulte a documentação oficial do Sentry para PHP para mais detalhes.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

getsentry/sentry-android-sdk

Full Sentry SDK setup for Android. Use when asked to "add Sentry to Android", "install sentry-android", "setup Sentry in Android", or configure error monitoring, tracing, profiling, session replay, or logging for Android applications. Supports Kotlin and Java codebases.

getsentry/sentry-browser-sdk

Full Sentry SDK setup for browser JavaScript. Use when asked to "add Sentry to a website", "install @sentry/browser", or configure error monitoring, tracing, session replay, or logging for vanilla JavaScript, jQuery, static sites, or WordPress.

getsentry/sentry-cloudflare-sdk

Full Sentry SDK setup for Cloudflare Workers and Pages. Use when asked to "add Sentry to Cloudflare Workers", "install @sentry/cloudflare", or configure error monitoring, tracing, logging, crons, or AI monitoring for Cloudflare Workers, Pages, Durable Objects, Queues, Workflows, or Hono on Cloudflare.

getsentry/sentry-cocoa-sdk

Full Sentry SDK setup for Apple platforms (iOS, macOS, tvOS, watchOS, visionOS). Use when asked to "add Sentry to iOS", "add Sentry to Swift", "install sentry-cocoa", or configure error monitoring, tracing, profiling, session replay, logging, or metrics for Apple applications. Supports SwiftUI and UIKit.

getsentry/sentry-code-review

Analyze and resolve Sentry comments on GitHub Pull Requests. Use this when asked to review or fix issues identified by Sentry in PR comments. Can review specific PRs by number or automatically find recent PRs with Sentry feedback.

getsentry/sentry-create-alert

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.

getsentry/sentry-dotnet-sdk

Full Sentry SDK setup for .NET. Use when asked to "add Sentry to .NET", "install Sentry for C#", or configure error monitoring, tracing, profiling, logging, or crons for ASP.NET Core, MAUI, WPF, WinForms, Blazor, Azure Functions, or any other .NET application.

getsentry/sentry-elixir-sdk

Full Sentry SDK setup for Elixir. Use when asked to "add Sentry to Elixir", "install sentry for Elixir", or configure error monitoring, tracing, logging, or crons for Elixir, Phoenix, or Plug applications. Supports Phoenix, Plug, LiveView, Oban, and Quantum.

getsentry/sentry-feature-setup

Configure specific Sentry features beyond basic SDK setup. Use when asked to monitor AI/LLM calls, set up OpenTelemetry pipelines, create alerts and notifications, or enable span streaming.

getsentry/sentry-fix-issues

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.

getsentry/sentry-flutter-sdk

Full Sentry SDK setup for Flutter and Dart. Use when asked to "add Sentry to Flutter", "install sentry_flutter", "setup Sentry in Dart", or configure error monitoring, tracing, profiling, session replay, or logging for Flutter applications. Supports Android, iOS, macOS, Linux, Windows, and Web.

getsentry/sentry-go-sdk

Full Sentry SDK setup for Go. Use when asked to "add Sentry to Go", "install sentry-go", "setup Sentry in Go", or configure error monitoring, tracing, logging, metrics, or crons for Go applications. Supports net/http, Gin, Echo, Fiber, FastHTTP, Iris, Negroni, and gRPC.

getsentry/sentry-nestjs-sdk

Full Sentry SDK setup for NestJS. Use when asked to "add Sentry to NestJS", "install @sentry/nestjs", "setup Sentry in NestJS", or configure error monitoring, tracing, profiling, logging, metrics, crons, or AI monitoring for NestJS applications. Supports Express and Fastify adapters, GraphQL, microservices, WebSockets, and background jobs.

getsentry/sentry-nextjs-sdk

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.

getsentry/sentry-node-sdk

Full Sentry SDK setup for Node.js, Bun, and Deno. Use when asked to "add Sentry to Node.js", "add Sentry to Bun", "add Sentry to Deno", "install @sentry/node", "@sentry/bun", or "@sentry/deno", or configure error monitoring, tracing, logging, profiling, metrics, crons, or AI monitoring for server-side JavaScript/TypeScript runtimes.

getsentry/sentry-otel-exporter-setup

Configure the OpenTelemetry Collector with Sentry Exporter for multi-project routing and automatic project creation. Use when setting up OTel with Sentry, configuring collector pipelines for traces and logs, or routing telemetry from multiple services to Sentry projects.

getsentry/sentry-pr-code-review

Review a project's PRs to check for issues detected in code review by Seer Bug Prediction. Use when asked to review or fix issues identified by Sentry in PR comments, or to find recent PRs with Sentry feedback.

getsentry/sentry-python-sdk

Full Sentry SDK setup for Python. Use when asked to "add Sentry to Python", "install sentry-sdk", "setup Sentry in Python", or configure error monitoring, tracing, profiling, logging, metrics, crons, or AI monitoring for Python applications. Supports Django, Flask, FastAPI, Celery, Starlette, AIOHTTP, Tornado, and more.

getsentry/sentry-react-native-sdk

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.

getsentry/sentry-react-sdk

Full Sentry SDK setup for React. Use when asked to "add Sentry to React", "install @sentry/react", or configure error monitoring, tracing, session replay, profiling, or logging for React applications. Supports React 16+, React Router v5-v7 non-framework mode, TanStack Router, Redux, Vite, and webpack.

Habilidades Relacionadas