support-laravel maintained by deftstar
deftstar/support-laravel
Turn server-side errors in a Laravel app into Support tickets that carry the real server detail — no Sentry required (Support is the store).
On a 5xx it stamps a correlation id on the response and buffers the exception
detail (message, class, file:line, route, method, status, user, stack) locally for
a short TTL. The detail is pushed to Support only if the user reports it — so
Support never stores errors nobody reported, and the detail stays server-side until
then. The browser's Support widget reads the id off the failed response; on report,
the frontend hits the flush endpoint and files a ticket referencing the id, and
Support joins the two so the agent sees the stack.
Install
composer require deftstar/support-laravel
php artisan vendor:publish --tag=support-config # optional; config works via env
Set two env vars:
SUPPORT_SECRET_KEY=sk_... # your project secret (never exposed to the browser)
SUPPORT_INGEST_URL=https://support-api.deftstar.dev/api/ingest/errors
The service provider is auto-discovered; it registers a global middleware (stamps
X-Request-Id), a reportable() callback (buffers 5xx detail), and a flush route.
No changes to your Kernel or Handler.
Protect the flush endpoint with your app's auth (default ['auth']). For an API:
// config/support.php
'flush' => ['path' => 'support/errors/flush', 'middleware' => ['auth:api']],
How it works (report-gated)
- Middleware stamps
X-Request-Idon every response and stashes it on the request. - A
reportable()callback buffers 5xx detail in your cache (config('support.ttl')minutes), keyed by that id. It does not push. Use a shared cache (Redis) if you run multiple instances. - When a user reports, the frontend
POSTs the id to the flush route, which pushes that one buffered error to Support. Errors nobody reports are never sent and expire from the cache.
Best-effort — a Support outage never affects your app. Leave SUPPORT_SECRET_KEY empty
to disable reporting entirely.
Frontend
Pair this with the Support widget so users can turn a 500 into a ticket:
@deftstar/support-widget— the widget loader (SupportWidget.reportError(...)).@deftstar/support-angular— an Angular interceptor that offers "Report a problem" on a 5xx automatically. (Any framework can wire its own HTTP hook.)
Notes
- Requires PHP 8.1+, Laravel 10/11/12.
- Uses
app()->terminating(), notIlluminate\Support\defer()— the latter does not reliably flush under php-fpm.