dakenf/release-profiler-bundle
Installation Add the bundle via Composer:
composer require dakenf/release-profiler-bundle
Register the bundle in config/bundles.php (Symfony 4+):
return [
// ...
Dakenf\ReleaseProfilerBundle\DakenfReleaseProfilerBundle::class => ['all' => true],
];
Configuration Publish the default config:
php bin/console dakenf:release-profiler:install
Edit config/packages/dakenf_release_profiler.yaml to enable:
request_logging (default: false)error_reporting (default: false)slack_webhook_url or mailer_transport).First Use Case Trigger a test error in a controller:
public function testError()
{
throw new \RuntimeException('Test error for ReleaseProfiler');
}
Verify the error appears in Slack/Email (if configured) or logs.
Request Logging
request_logging: true in config.sensitive_data_fields in config).Error Reporting
error_reporting: true.slack_message_format (e.g., *Error*: {{ exception }}).mailer_from and mailer_to; customize subject with mailer_subject.Integration with Monolog
monolog channel (default: release_profiler).config/packages/monolog.yaml:
handlers:
release_profiler:
type: stream
path: "%kernel.logs_dir%/release_profiler.log"
level: debug
Conditional Logging
# config/packages/dakenf_release_profiler.yaml
enabled: '%env(bool:RELEASE_PROFILER_ENABLED)%'
Custom Error Handlers
Extend the bundle’s ErrorListener to filter exceptions:
// src/EventListener/CustomErrorListener.php
namespace App\EventListener;
use Dakenf\ReleaseProfilerBundle\Event\ErrorEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class CustomErrorListener implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
'release_profiler.error' => 'onError',
];
}
public function onError(ErrorEvent $event)
{
if ($event->getException() instanceof \Symfony\Component\HttpKernel\Exception\HttpException) {
$event->stopPropagation(); // Skip reporting for HTTP errors
}
}
}
Dynamic Slack/Email Recipients Use a service to resolve recipients dynamically:
# config/packages/dakenf_release_profiler.yaml
slack_webhook_url: '%env(SLACK_WEBHOOK_URL)%'
slack_recipients: '@app\Service\SlackRecipientResolver'
Performance Overhead
dev:
request_logging: '%kernel.debug% ? false : true'
excluded_routes:
- '^/admin'
- '^/api/v1/tokens'
Slack/Email Delays
php bin/console debug:container dakenf_release_profiler.slack_notifier
Stack Trace Truncation
slack_max_message_length (default: 2000).Configuration Conflicts
monolog is configured before release_profiler in bundles.php to avoid handler conflicts.Log Levels
Use debug level for verbose output:
handlers:
release_profiler:
level: debug
Test Locally Simulate errors with:
php bin/console debug:exception --format=json > error.json
Pipe output to Slack/Email for testing.
Clear Logs Rotate logs manually:
php bin/console debug:config monolog | grep handlers
Custom Notifiers
Implement Dakenf\ReleaseProfilerBundle\Notifier\NotifierInterface:
class HipChatNotifier implements NotifierInterface
{
public function notify(ErrorEvent $event)
{
// Custom HipChat logic
}
}
Register in services:
services:
App\Notifier\HipChatNotifier:
tags: ['release_profiler.notifier']
Request Data Sanitization
Override RequestDataSanitizer to strip PII:
class CustomSanitizer implements RequestDataSanitizerInterface
{
public function sanitize(array $data): array
{
unset($data['password'], $data['credit_card']);
return $data;
}
}
Bind in services.yaml:
Dakenf\ReleaseProfilerBundle\Sanitizer\RequestDataSanitizerInterface: '@App\Sanitizer\CustomSanitizer'
Event Subscribers
Listen to release_profiler.request or release_profiler.error:
public static function getSubscribedEvents()
{
return [
'release_profiler.request' => 'onRequest',
'release_profiler.error' => 'onError',
];
}
Environment Variables
Prefix with RELEASE_PROFILER_ for consistency:
slack_webhook_url: '%env(RELEASE_PROFILER_SLACK_WEBHOOK)%'
Default Values
Override defaults in config/packages/dakenf_release_profiler.yaml:
request_logging:
enabled: true
exclude_headers: ['authorization', 'cookie']
How can I help you explore Laravel packages today?