Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Rollbar Symfony Bundle Laravel Package

sfertrack/rollbar-symfony-bundle

A Symfony bundle that integrates Rollbar error tracking, helping you capture and report exceptions and errors from your Symfony application to Rollbar through bundle configuration.

View on GitHub
Deep Wiki
Context7

Getting Started

Install and register

composer require sfertrack/rollbar-symfony-bundle

For Symfony Flex apps the bundle should be auto-registered; otherwise add it manually in config/bundles.php:

Sfertrack\RollbarBundle\SfertrackRollbarBundle::class => ['all' => true],

Find the config surface first. Before wiring anything, open the bundle's DependencyInjection/Configuration.php and its README. This package is a small, low-adoption fork (0 stars), so the canonical docs are the source tree rather than blog posts. Look for:

  • the config root alias (commonly rollbar or sfertrack_rollbar),
  • the service IDs it registers (the logger/reporter, and the Monolog handler),
  • which keys are required (access_token, environment) versus optional (person_fn, scrub_fields, minimum_level).

Minimum viable config (config/packages/rollbar.yaml):

rollbar:
    access_token: '%env(ROLLBAR_ACCESS_TOKEN)%'
    environment: '%env(ROLLBAR_ENV)%'
    enabled: '%env(bool:ROLLBAR_ENABLED)%'

Set the env vars per environment: a post_server_item token for prod/staging, ROLLBAR_ENABLED=false in dev and test.

First use case: catch uncaught exceptions. In most setups the bundle hooks kernel.exception automatically. Validate it by throwing deliberately in a controller:

public function boom(): Response
{
    throw new \RuntimeException('rollbar smoke test');
}

Then confirm the item appears in the Rollbar dashboard with the right environment, server.host, and code version. If nothing arrives, set enabled: true, run bin/console cache:clear, and check var/log/ for transport errors — this is the fastest way to distinguish a config problem from a network/token problem.

Second step: decide your entry point. You will almost always use one of three:

  1. Automatic exception capture (zero code),
  2. The Monolog handler (all error-level logs),
  3. The injectable reporter service for explicit reportMessage/reportException calls.

Pick (1) + (3) for typical apps; add (2) only if your logging discipline is already strong.

Implementation Patterns

Monolog handoff for warnings and above. Route a channel to the bundle's handler so every error/critical log ships, without duplicating exception reporting.

monolog:
    handlers:
        rollbar:
            type: service
            id: rollbar.handler          # confirm the real service ID in services.xml
            level: error
            bubble: true

Keep bubble: true so fingers_crossed/file handlers still receive the record.

Inject the reporter for explicit, contextual reports. Where you have rich domain context, report directly rather than relying on the exception listener:

final class PaymentService
{
    public function __construct(private RollbarLogger $rollbar) {}

    public function charge(Order $order): void
    {
        try {
            // ...
        } catch (GatewayException $e) {
            $this->rollbar->reportException($e, [
                'order_id' => $order->getId(),
                'gateway'  => 'stripe',
            ]);
            throw $e;
        }
    }
}

Attach the user and request context once. If the bundle ships a person provider hook, use it; otherwise add a small listener on kernel.request that sets Rollbar::getNotifier()->addCustomData(...) or the equivalent — this makes every downstream item searchable by user ID.

#[AsEventListener(event: KernelEvents::REQUEST)]
final class RollbarContextListener
{
    public function __invoke(RequestEvent $event): void
    {
        if (!$event->isMainRequest()) return;
        $req = $event->getRequest();
        Rollbar::addCustomData('route', $req->attributes->get('_route'));
        Rollbar::addCustomData('request_id', $req->headers->get('X-Request-Id'));
    }
}

Environment matrix. Treat Rollbar env as a first-class value, not a copy of APP_ENV:

# config/packages/prod/rollbar.yaml
rollbar:
    enabled: true
    environment: '%env(ROLLBAR_ENV)%'   # e.g. "production-eu"
    capture_email: false
    scrub_fields: ['password', 'token', 'authorization', 'cookie']

Framework-agnostic exception listener alternative. If the built-in listener is too coarse, disable it (rollbar.capture_exceptions: false) and write your own kernel.exception subscriber so you control what gets reported versus what gets re-thrown/rendered as a 4xx.

Fingerprinting for sane grouping. Pass fingerprint in the custom payload for exceptions that are otherwise grouped into one bucket (e.g. a generic ValidationException). This is the single highest-leverage tuning for signal-to-noise.

CLI and Messenger. Web requests get context automatically; console and worker processes do not. Add rollbar.environment awareness and push the command name / message class as custom data from a ConsoleEvents::COMMAND listener or a Messenger middleware, otherwise all worker errors land as anonymous.

Test strategy. Disable the bundle in test (ROLLBAR_ENABLED=0) so the SDK never attempts network calls during the suite; if you must assert reporting, replace the reporter service with a spy in config/services_test.yaml.

Gotchas and Tips

  • Maturity risk is the headline. 0 stars, 0 dependents, and a single-maintainer fork name mean you are on the critical path. Pin an exact version, vendor-review the DependencyInjection and handler code, and have an exit plan: the underlying rollbar/rollbar-php SDK plus a ~40-line Monolog handler and exception listener reproduces 90% of this bundle. Budget for that migration.
  • Double reporting. The automatic exception listener plus a Monolog handler on error will often ship the same exception twice. Either drop Monolog error records to a lower level or disable automatic capture; check the resulting item counts in Rollbar for a week.
  • Token vs. access token. Use the post_server_item token server-side. A client token will silently reject writes or, worse, a read token will appear to work in config validation but produce no items.
  • environment defaults are a trap. Many Rollbar integrations inherit APP_ENV; that splits your data into prod, production, and staging buckets the moment someone renames an env var. Set it explicitly in each config/packages/{env}/ file.
  • Sampling and quota. Configure minimum_level, captured_message_limit, and sampling/excluded exceptions before go-live. A noisy NotFoundHttpException or ConnectionException on a busy queue can burn a free-tier quota in a day.
  • PII and scrubbing. Verify scrub_fields covers authorization, cookie, set-cookie, php-auth-pw, and any domain-specific secrets. The scrubber runs on serialized payloads — nested keys inside objects are not always caught, so avoid putting raw request bodies in custom data.
  • Async transports lose context. If rollbar.transport is set to the curl or a queued transport, the payload is serialized after the response; custom data registered in a kernel.terminate listener may be missing. Register context in kernel.request/kernel.exception instead.
  • Config cache. Symfony caches bundle config aggressively. After changing the YAML you must cache:clear, and after changing the env var you may need cache:clear --env=prod — a common "why is it disabled?" red herring.
  • Extension points if the fork is stale. The two places worth patching locally are the person provider (to inject your UserInterface) and the exception listener (to add ignored_exceptions). Both are small classes and low-risk to override via service decoration.
  • Debugging tip. If reports vanish, first confirm enabled: true and the token format, then wrap a manual reportMessage('ping') in a controller; if that fails, the issue is transport/TLS (common behind corporate proxies or PHP builds without curl/openssl), not the bundle.
  • Flush on shutdown. For long-running workers (messenger:consume, RoadRunner/Swoole), call Rollbar::flush() (or the bundle's equivalent) at the end of each message/request cycle, or you will lose the last batch on process restart.
  • Frontend correlation. Pass X-Request-Id (or Rollbar's own UUID) down to Twig and into the JS SDK so frontend and backend items share a trace — trivial once request_id is in custom data, and it's what makes this bundle actually pay for itself during incidents.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
cgv/localized-resource