Runtime execution tracer for Laravel routes - Captures actual file dependencies and execution flow for any Laravel route.
To records the real execution path by capturing which files PHP actually loads during a request.
- Actual file dependencies - Not guessing
- Execution time - Real performance metrics
- Categorized files - Controllers, Models, Policies, etc.
- Exception tracking - Traces even when things break
- Zero config - Works out of the box
composer require tonygeez/laravel-route-tracer --devThe package will auto-register via Laravel's package discovery.
Publish Config (Optional)
php artisan vendor:publish --tag=route-tracer-configWrap your routes with the trace middleware:
use TonyGeez\LaravelRouteTracer\Middleware\TraceRouteDependencies;
// Enable for next request
TraceRouteDependencies::enable();
Route::middleware(['trace-route'])->group(function () {
Route::get('/api/users', [UserController::class, 'index']);
Route::post('/api/users', [UserController::class, 'store']);
});# Enable tracing for next request
php artisan route:trace-enable
# Enable for specific routes
php artisan route:trace-enable api.users.index api.users.store
# Disable tracing
php artisan route:trace-disable
# View traces
php artisan route:trace-view
# View latest trace only
php artisan route:trace-view --latest
# Filter by route name
php artisan route:trace-view --route=api.usersuse TonyGeez\LaravelRouteTracer\Facades\RouteTracer;
// Enable tracing
RouteTracer::enable();
// Enable for specific routes
RouteTracer::enableForRoutes(['api.users.index', 'api.orders.show']);
// Check if enabled
if (RouteTracer::isEnabled()) {
// ...
}
// Disable
RouteTracer::disable();Set in .env:
ROUTE_TRACER_ENABLED=trueExample Output
{
"route": "api.users.index",
"uri": "/api/v1/users",
"controller": "App\\Http\\Controllers\\UserController@index",
"method": "GET",
"files_loaded_count": 12,
"files_loaded": {
"controllers": [
"app/Http/Controllers/UserController.php"
],
"models": [
"app/Models/User.php"
],
"policies": [
"app/Policies/UserPolicy.php"
],
"resources": [
"app/Http/Resources/UserResource.php"
],
"migrations": [
"database/migrations/2024_01_01_000000_create_users_table.php"
]
},
"memory_used_mb": 2.5,
"execution_time_ms": 45.2,
"timestamp": "2024-01-15T10:30:45+00:00"
}
All options can be configured via config/route-tracer.php
return [
// Enable globally
'enabled' => env('ROUTE_TRACER_ENABLED', false),
// Output format: 'json' or 'markdown'
'output_format' => env('ROUTE_TRACER_FORMAT', 'json'),
// Log channel
'log_channel' => env('ROUTE_TRACER_LOG_CHANNEL', 'stack'),
// Exclude patterns
'exclude_patterns' => [
'/vendor/',
'/bootstrap/',
'/storage/',
],
];