kick-in/exception-handler-bundle
Kick-in Exception Handler Bundle is a Symfony bundle for centralized exception handling. Configure handlers, map exceptions to consistent responses, and keep controllers clean with flexible error reporting and an integration-friendly setup.
This is a Symfony bundle, not a Laravel package. As a Laravel developer, treat it as either:
app/Exceptions/Handler.php.Minimal Symfony setup if you are actually in a Symfony app:
composer require kick-in/exception-handler-bundle
Then:
config/bundles.php:
KickIn\ExceptionHandlerBundle\ExceptionHandlerBundle::class => ['all' => true],
README and DependencyInjection/Configuration.php first. That is the source of truth for config keys, mailer requirements, and recipient settings.First realistic use case: replace generic “something went wrong” alerts with an email containing the exact exception and enough context to reproduce it. In Laravel terms, this is similar to customizing report() in app/Exceptions/Handler.php and sending a Mailable, but the Symfony bundle handles the wiring for you.
Where to look first:
README.md for install and config.The most sensible pattern is environment gating:
In Symfony, this means keeping the bundle enabled but configuring recipients and mail behavior per environment. In Laravel, the equivalent is:
// app/Exceptions/Handler.php
public function report(Throwable $e): void
{
if (app()->environment('production') && $this->shouldMail($e)) {
Mail::to(config('services.alerts.email'))
->queue(new ExceptionOccurred($e, request()));
}
parent::report($e);
}
Do not mail every exception. A single broken request path can generate thousands of mails. Patterns:
send().Laravel equivalent:
RateLimiter::attempt(
'exception-mail:'.md5($e::class.$e->getMessage()),
1,
fn () => Mail::to($to)->queue(new ExceptionOccurred($e)),
300
);
If the bundle’s handler is a service, decorate it or add an event listener rather than editing vendor files. This keeps upgrades possible.
In Laravel, the same principle applies: put custom reporting in report() or a dedicated reporter service, not inside framework internals.
Email is a notification channel, not an observability system. Use it alongside:
Log::critical(), Sentry, Flare, Bugsnag, etc.Recommended flow:
Create domain-specific exceptions such as PaymentFailedException or SyncJobFailedException. Then decide which ones should trigger mail. This avoids brittle message-string matching.
HTTP exceptions are not the only source. If you use the same pattern in Laravel queue jobs or Symfony console commands, make sure the mailer context still captures:
Use Mailpit, MailHog, or Symfony Mailer’s log transport during development. Assert that:
Do not run composer require kick-in/exception-handler-bundle in a Laravel app expecting package discovery, a service provider, or a config/exception-handler.php file. It will not integrate with Laravel’s exception handler. Port the idea, not the dependency.
With 1 star and 0 dependents, expect limited community documentation, few Stack Overflow answers, and possible edge-case bugs. Read the source before relying on it in production. Pin the version in composer.json.
A failure inside the mailer can trigger another exception, which can trigger another mail attempt. Guard against this:
PHP fatal errors, OOM kills, and process crashes can bypass normal exception handling. Email alerting alone is not enough. Use shutdown handlers, server-level monitoring, and log aggregation.
After changing bundle config, clear the cache:
php bin/console cache:clear
In production, ensure config is rebuilt during deploy. A stale config cache can make it look like the bundle is ignoring your recipients or transport settings.
Confirm whether the bundle expects Symfony Mailer, SwiftMailer, or a generic mailer service. Older Symfony bundles may assume deprecated APIs. Check composer.json constraints against your Symfony version.
If the bundle sends mail inline, an SMTP timeout can turn a 500 into a very slow 500. Prefer async transports or queued messages where possible.
Exception mails often include request parameters, headers, SQL, and environment details. Redact authorization headers, cookies, passwords, API tokens, and personal data before sending.
If mail is not arriving:
var/log for mailer transport errors.Look for:
These are the safest places to customize without forking the bundle.
If your goal is simply “email me the exact exception,” do not introduce a Symfony bundle into Laravel. Use Laravel’s native facilities:
app/Exceptions/Handler.php for reporting.Mail::to(...)->queue(...) for delivery.RateLimiter for throttling.Log and a monitoring package for observability.ExceptionOccurred mailable with redacted context.That gives you the same outcome with first-class Laravel support and no cross-framework coupling.
How can I help you explore Laravel packages today?