Laravel Time Machine: A Request Lifecycle Profiler

Last updated on by

Laravel Time Machine: A Request Lifecycle Profiler image

Laravel Time Machine is a performance profiler by Jaydeep Gadhiya that records every stage of a Laravel request — bootstrap, middleware, routing, controller, response, and termination — with millisecond timings. It answers one question: where did the time go in this request?

Here's what the package gives you:

  • Lifecycle timeline — a Gantt-style breakdown of each request phase, from framework boot through the terminate step.
  • Query capture — every SQL statement with bindings, connection, and execution time, toggled via collectors.queries.
  • Slow highlighting — requests over 500ms and queries over 50ms get flagged, with both thresholds configurable.
  • Flat-file storage — profiles are plain JSON files in storage/time-machine; no database tables or migrations.
  • Ignore patterns — asset requests and paths like the Telescope dashboard are skipped via ignore_paths.
  • Debug-only by default — the profiler follows APP_DEBUG, so it stays off in production unless you enable it.

The Timeline Dashboard

Once installed, the package records every HTTP request automatically and serves a self-contained dashboard at /time-machine when enabled. Each request gets a visual timeline showing how long the application spent in each lifecycle phase, alongside memory usage and query counts. Requests that cross the slow threshold (500ms by default) are highlighted so bottlenecks stand out in the list of recent profiles.

Custom Instrumentation

Beyond the automatic lifecycle phases, you can instrument your own code through the TimeMachine facade. Drop point-in-time markers, wrap a block in a measured closure, or control spans manually:

use Jaydeep\LaravelTimeMachine\Facades\TimeMachine;
 
// Drop a marker on the timeline
TimeMachine::mark('cache primed');
 
// Time a code block
$report = TimeMachine::measure('generate-report', function () {
return Report::build();
});
 
// Manual span control
TimeMachine::startSpan('external-api');
$response = Http::get('https://api.example.com');
TimeMachine::endSpan('external-api');

Custom spans appear on the same timeline as the framework phases, so you can see how a slow external API call or report generation fits into the overall request.

Storage Without a Database

Profiles are written as JSON files to storage/time-machine, which means there are no migrations to run and the data never leaves your server. The package retains the most recent 100 profiles by default and prunes the oldest ones as new requests come in; the storage.max_records setting (or the TIME_MACHINE_MAX_RECORDS env variable) adjusts the limit.

How It Compares to Telescope and Debugbar

There's some overlap with Laravel Telescope and Laravel Debugbar, but the three tools have different scopes. Telescope monitors many parts of an application — requests, jobs, mail, notifications, cache, and more — and stores its entries in the database.

Debugbar renders a toolbar inside the current page with timing and query data for that response.

Time Machine sits in between: it keeps a browsable history of recent requests like Telescope, but collects only lifecycle timing and query data, stores it in flat files, and presents it on a timeline. If you want full application monitoring, Telescope is still the better fit; if you're profiling where individual requests spend their time, that's the case this package is built for.

Installation and Configuration

The package supports Laravel 8 through 13, and installs via Composer with auto-discovery handling the service provider and facade:

composer require jaydeep/laravel-time-machine

Publishing the config file is optional:

php artisan vendor:publish --tag=time-machine-config

You can learn more about this package, get full installation instructions, and view the source code on the laravel-timemachine GitHub repository.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Tinkerwell

Enjoy coding and debugging in an editor designed for fast feedback and quick iterations. It's like a shell for your application – but with multi-line editing, code completion, and more.

Visit Tinkerwell
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $9500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell

The latest

View all →
Laravel SMS Catcher: A Local Dashboard for SMS Notifications image

Laravel SMS Catcher: A Local Dashboard for SMS Notifications

Read article
The Analytics Stack for Laravel: Traffic, Revenue and Attribution in One Place image

The Analytics Stack for Laravel: Traffic, Revenue and Attribution in One Place

Read article
Scaffold Packages with the `laravel package` Command in Laravel Installer v5.31.0 image

Scaffold Packages with the `laravel package` Command in Laravel Installer v5.31.0

Read article
Vocalizer: Local Text-to-Speech for PHP image

Vocalizer: Local Text-to-Speech for PHP

Read article
Build a Laravel Scout Search Endpoint With the HTTP QUERY Method image

Build a Laravel Scout Search Endpoint With the HTTP QUERY Method

Read article
Enforce Per-Action Waiting Periods in Laravel with Cooldown image

Enforce Per-Action Waiting Periods in Laravel with Cooldown

Read article