laravel-debug-tracer maintained by akhtar
Laravel Debug Session Tracer
Minimal, file-based API lifecycle tracing for Laravel.
This package is now focused only on tracing API request/response/error lifecycle events. No Trace ID filtering, no admin/debug extras, and no job debugging.
Install
composer require akhtar/laravel-debug-tracer
Publish configuration
php artisan vendor:publish --tag=debug-tracer-config
Required configuration
Set these in .env:
DEBUG_TRACER_ENABLED=true
DEBUG_TRACER_TTL_MINUTES=30
DEBUG_TRACER_MATCHING_HEADER=X-Debug-Token
Config (config/debug-tracer.php) options used in this minimal mode:
enabledsession_ttl_minutesstorage_pathmatching_headerroute_middlewareregister_routesattach_api_middleware
Scheduler setup (recommended)
The package provides debug-tracer:cleanup and auto-schedules it every 5 minutes.
Make sure your app scheduler is running in your environment:
php artisan schedule:work
Routes
POST /debug/startPOST /debug/stopGET /debug/export/{session_id}GET /debug-dashboardGET /debug-dashboard/logs/{session_id}
Lifecycle behavior
Start session
POST /debug/start
Body:
{
"token": "Bearer 3011|your-api-token"
}
What happens:
- All old session files in storage are removed.
- A new active session is created.
- New API lifecycle events are appended to this session file.
Stop session
POST /debug/stop
Body:
{
"session_id": "uuid"
}
Header:
X-Debug-Token: your-api-token
What happens:
- Session ownership is validated by token.
- Session meta/log files are deleted immediately.
- Export is no longer possible for that stopped session.
Export logs
GET /debug/export/{session_id}?token=Bearer your-api-token
Returns NDJSON of captured API lifecycle entries.
Dashboard behavior
In /debug-dashboard:
- Start button is disabled while a session is active.
- Stop and Export are disabled until a session is active.
- After stop, Stop and Export are disabled again.
- The UI only shows API request/response/error lifecycle details.
Storage
Default path:
storage/debug-traces/{session_id}.meta.jsonstorage/debug-traces/{session_id}.log
On new session start, all old files are deleted first. On stop, current session files are deleted immediately.