mekras/obereg-bundle
Obereg is a lightweight PHP bundle that adds a reusable protection layer to your application, packaging common guard and safety checks as configurable services. Install with Composer, enable the bundle, and set the rules that fit your project. Small footprint, sensible defaults, and easy integration...
OberegBundle is a Symfony bundle (mekras/obereg-bundle), not a Laravel package. There is no service provider, no config/obereg.php, no Facade, and no package auto-discovery. It wires itself into Symfony's kernel.exception event via the bundle registration in AppKernel, so there is no path to installing it into a Laravel app with composer require and having it "just work." The last tagged release is from 2015-05-07 and it targets the Symfony 2.x API and PHP 5.x era.
Where to look first, if you are evaluating it:
composer.json — check the symfony/symfony and php constraints. They will confirm it cannot resolve against a modern Symfony, let alone Laravel.kernel.exception — this is the whole product: intercept an exception, decide what to render, set a Response, and stop propagation.Configuration class / extension) — this shows how exception classes are mapped to status codes and templates.First use case it was built for (on Symfony): replace the default Twig "Oops" page with per-exception-class error pages, and return JSON for API-style requests instead of HTML. In Laravel, the day-to-day equivalent is App\Exceptions\Handler (Laravel ≤10) or bootstrap/app.php → ->withExceptions(...) (Laravel 11+). Start there; borrow the concept, not the code.
Since you cannot run the bundle in Laravel, the practical pattern is to reimplement its idea — centralized, type-aware error rendering — in Laravel's native exception pipeline.
Exception-class → response mapping. In withExceptions() (Laravel 11+) or Handler::register(), bind specific exception types to status codes and payloads:
->withExceptions(function (Exceptions $exceptions) {
$exceptions->render(function (DomainException $e, Request $request) {
return $request->expectsJson()
? response()->json(['error' => $e->getMessage()], 422)
: response()->view('errors.domain', ['e' => $e], 422);
});
})
This mirrors what Obereg's listener did with its exception→template configuration.
Content negotiation. Obereg decided between HTML and JSON output. Laravel's $request->expectsJson() (or $request->is('api/*')) is the equivalent and is more reliable than sniffing Accept by hand.
Keep controllers thin. The whole point of an error-handling bundle is that controllers do not try/catch for presentation. Preserve that discipline: let exceptions bubble, render centrally.
Reporting vs rendering. Obereg-style bundles usually conflate logging and rendering; Laravel separates them. Use report()/$exceptions->report(...) for logging and render() for output. Do not log inside a renderer.
If you genuinely need to read the Symfony source (e.g., you are porting an app off Symfony 2): the listener pattern is event->setResponse($response) to short-circuit, and listener priority determines which handler wins. Map that mental model onto Laravel's renderable ordering.
OberegServiceProvider, no extra.laravel block, no auto-discovery. Any integration would be a from-scratch port, at which point you have written more code than withExceptions() needs.config('app.debug') and never render $e->getTrace() outside local.AppKernel::registerBundles() has no Laravel analogue. Do not look for a config/app.php providers entry; it isn't there.kernel.debug and the profiler's exception panel are where you inspect it; listener priority bugs manifest as "my handler never fires." The Laravel equivalent for "my renderer never fires" is checking that a more specific renderable (or a Responsable/render() method on the exception itself) is not winning.renderable closures — but implement it yourself; do not resurrect the bundle to get it.How can I help you explore Laravel packages today?