Installation:
composer require dbstudios/airbrake-bundle
Add to AppKernel.php:
new DaybreakStudios\Bundle\AirbrakeBundle\DaybreakStudiosAirbrakeBundle(),
Configuration:
Add to config/parameters.yml:
parameters:
airbrake.api_key: 'YOUR_API_KEY'
airbrake.project_id: YOUR_PROJECT_ID
Enable in config/config.yml:
daybreak_studios_airbrake:
enabled: false # Set to `true` in `config_prod.yml`
api_key: %airbrake.api_key%
project_id: %airbrake.project_id%
First Use Case:
Deploy to production (APP_ENV=prod). Exceptions will now auto-report to Airbrake.
Exception Handling:
try/catch or throw changes required.Contextual Data:
Airbrake service:
$this->get('daybreak_studios_airbrake.service.airbrake')->addContext('user_id', $user->id);
environment and appVersion (set via config or code).Ignored Exceptions:
daybreak_studios_airbrake:
ignored_exceptions:
- Symfony\Component\HttpKernel\Exception\HttpExceptionInterface
Monolog Integration (Optional):
WARNING+) to Airbrake:
# services.yml
airbrake_log_watcher:
class: DaybreakStudios\Bundle\AirbrakeBundle\Logging\AirbrakeHandler
arguments: ['@daybreak_studios_airbrake.service.airbrake', 'Monolog\Logger::WARNING']
config.yml:
monolog:
handlers:
airbrake:
type: service
id: airbrake_log_watcher
Dynamic Configuration:
config_prod.yml):
daybreak_studios_airbrake:
enabled: true
environment: production
appVersion: 1.0.0
API Key Exposure:
%airbrake.api_key% in config.yml (use parameters.yml)..env or parameters.yml for sensitive data.Monolog Handler Conflicts:
monolog.logger service in Symfony’s profiler or logs.Ignored Exceptions:
\Exception) may hide critical errors.App\Exception\PaymentFailedException).Deprecated Symfony Support:
sentry/sentry-symfony.Network Issues:
$airbrake = $this->get('daybreak_studios_airbrake.service.airbrake');
try {
$airbrake->notify($exception);
} catch (\Exception $e) {
$this->get('logger')->error('Airbrake failed', ['exception' => $e]);
}
Context Enrichment:
$airbrake->addContext('request', [
'url' => $request->getUri(),
'method' => $request->getMethod(),
]);
Environment-Specific Config:
%kernel.environment% to conditionally enable features:
daybreak_studios_airbrake:
enabled: %kernel.environment% == 'prod'
Testing:
Airbrake service in tests:
$this->container->set('daybreak_studios_airbrake.service.airbrake', $this->createMock(Airbrake::class));
Performance:
# config_dev.yml
daybreak_studios_airbrake:
enabled: false
Alternatives:
sentry/sentry-laravel (Laravel) or sentry/sentry-symfony (Symfony).How can I help you explore Laravel packages today?