# Ruby & PHP

> **For agents:** paste the DSN from `list_keys` into the snippet for the platform; create the project with the matching platform id (`create_project(org="acme", slug="web", name="Web", platform="rails")`). Platforms on this page: `rails`, `laravel`, `symfony`.

Rails uses `sentry-ruby` + `sentry-rails`; Laravel and Symfony use the official Sentry bundle for the framework. All three hook the framework's exception path, console/rake commands, and job runners once configured. The one recurring surprise: exceptions you rescue yourself are not reported unless you capture them explicitly.

Replace `https://<public_key>@ingest.bugwatch.io/<project_number>` with the DSN from `list_keys` or the project's settings page.

## Ruby on Rails

- Platform id: `rails` · Language: Ruby · Runs in: server
- Install: `bundle add sentry-ruby sentry-rails`
- Files: config/initializers/sentry.rb

```ruby
Sentry.init do |config|
  config.dsn = "https://<public_key>@ingest.bugwatch.io/<project_number>"
  config.breadcrumbs_logger = [:active_support_logger, :http_logger]
  config.traces_sample_rate = 1.0
  config.release = ENV["RELEASE"]
  config.send_default_pii = false
end
```

Lifecycle notes:

- The initializer runs on boot for the app server, console and rake tasks; ActionController, ActiveJob and ActionMailer are instrumented automatically.
- Sidekiq/Resque: add sentry-sidekiq so job failures report with retry context.
- Rescued exceptions (rescue_from) are NOT reported unless you call Sentry.capture_exception in the handler.

## Laravel

- Platform id: `laravel` · Language: PHP · Runs in: server
- Install: `composer require sentry/sentry-laravel && php artisan sentry:publish`
- Files: .env · bootstrap/app.php

```php
# .env
SENTRY_LARAVEL_DSN=https://<public_key>@ingest.bugwatch.io/<project_number>
SENTRY_TRACES_SAMPLE_RATE=1.0
SENTRY_RELEASE=${APP_VERSION}

// bootstrap/app.php (Laravel 11+)
->withExceptions(function (Exceptions $exceptions) {
    Integration::handles($exceptions);
})
```

Lifecycle notes:

- The service provider auto-registers; reporting happens in the exception handler (Integration::handles) so report()-ed exceptions and unhandled ones both flow.
- Queue jobs, scheduled commands and Octane workers are instrumented — Octane needs the sentry:publish config for per-request scope reset.
- Use `php artisan sentry:test` to send a verification event before shipping.

## Symfony

- Platform id: `symfony` · Language: PHP · Runs in: server
- Install: `composer require sentry/sentry-symfony`
- Files: config/packages/sentry.yaml

```yaml
sentry:
  dsn: "https://<public_key>@ingest.bugwatch.io/<project_number>"
  options:
    traces_sample_rate: 1.0
    release: "%env(RELEASE)%"
```

Lifecycle notes:

- The bundle listens on kernel.exception and console.error; Messenger handlers report per message.

## Symbolication for this family

Ruby and PHP report readable frames directly; there is nothing to upload. Set `release` (env var or `@project.version@`-style) so release health and regression detection line up with deploys.
