Installation Add the package via Composer:
composer require culabs/bugcatch-bundle
Enable the bundle in config/bundles.php:
return [
// ...
Culabs\BugCatchBundle\CulabsBugCatchBundle::class => ['all' => true],
];
Configuration Publish the default config:
php bin/console culabs:bugcatch:install
Update config/packages/culabs_bugcatch.yaml with your BugCatch API key:
culabs_bugcatch:
api_key: 'your_api_key_here'
environment: 'production' # or 'development'
First Use Case Trigger an error to test integration:
// In a controller or service
throw new \RuntimeException('Test error for BugCatch');
Verify the error appears in your BugCatch dashboard.
Automatic Capture The bundle auto-captures uncaught exceptions and logs them to BugCatch. No manual instrumentation needed for most cases.
Manual Error Logging Explicitly log errors for critical paths:
use Culabs\BugCatchBundle\Logger\BugCatchLogger;
$logger = $container->get('bugcatch.logger');
$logger->error('Custom error message', ['context' => ['user_id' => 123]]);
use Culabs\BugCatchBundle\Monitor\BugCatchMonitor;
public function index(BugCatchMonitor $monitor) {
$monitor->start('controller.index');
// ... logic
$monitor->stop();
}
Event Listeners
Attach to kernel events (e.g., kernel.exception) for custom logic:
# config/services.yaml
services:
App\EventListener\BugCatchListener:
tags:
- { name: kernel.event_listener, event: kernel.exception, method: onKernelException }
Dependency Injection
Inject BugCatchClient directly where needed:
public function __construct(private BugCatchClient $bugCatch) {}
API Key Exposure Avoid hardcoding keys in version-controlled files. Use environment variables:
# .env
BUGCATCH_API_KEY=your_api_key
Then reference in config:
culabs_bugcatch:
api_key: '%env(BUGCATCH_API_KEY)%'
Sensitive Data Exclude sensitive data (e.g., passwords) from logs:
culabs_bugcatch:
filter_sensitive_data: true
Disable in Development
Temporarily disable logging in config/packages/culabs_bugcatch.yaml:
culabs_bugcatch:
enabled: false
Check HTTP Client Ensure the underlying HTTP client (Guzzle) isn’t blocked by firewall/proxy.
Custom Payloads Extend the logger to add metadata:
$logger->error('Payment failed', [
'amount' => $order->amount,
'user_agent' => $request->headers->get('User-Agent'),
]);
Batch Processing
For high-volume errors, use the batch method:
$logger->batch([
['message' => 'Error 1', 'level' => 'error'],
['message' => 'Error 2', 'level' => 'warning'],
]);
Async Logging Configure the bundle to use a queue system (e.g., Symfony Messenger) for non-blocking logs:
culabs_bugcatch:
use_async: true
How can I help you explore Laravel packages today?