What Is Laravel Time Machine?
Laravel Time Machine is an open-source performance profiler by Jaydeep Gadhiya that answers one question: where did the time go in this request? It hooks into every stage of the Laravel request lifecycle — bootstrap, middleware, routing, controller, response, and termination — and records millisecond-accurate timings for each phase.
The package is enabled by APP_DEBUG by default, so it stays off in production unless you explicitly turn it on.
Key Features at a Glance
- Lifecycle timeline — a Gantt-style breakdown from framework boot through the
terminatestep. - Query capture — every SQL statement with bindings, connection name, and execution time (toggle via
collectors.queries). - Slow highlighting — requests over 500 ms and queries over 50 ms are flagged; both thresholds are configurable.
- Flat-file storage — profiles are plain JSON files in
storage/time-machine; no migrations needed. - Ignore patterns — asset requests and paths like the Telescope dashboard can be skipped via
ignore_paths. - Debug-only by default — follows
APP_DEBUGso production stays clean.
The Timeline Dashboard
Once installed, the package records every HTTP request automatically and serves a self-contained dashboard at /time-machine. Each entry shows a visual timeline of lifecycle phases alongside memory usage and query counts. Requests that cross the slow threshold are highlighted so bottlenecks stand out immediately.
Custom Instrumentation with the TimeMachine Facade
Beyond automatic lifecycle phases, you can instrument your own code using the TimeMachine facade:
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 framework phases, making it easy to see how a slow external API call or a heavy report fits into the overall request.
Storage Without a Database
Profiles are written as JSON files to storage/time-machine. There are no migrations to run and data never leaves your server. The package retains the 100 most recent profiles by default, pruning the oldest as new requests arrive. Adjust the limit with storage.max_records in the config file or the TIME_MACHINE_MAX_RECORDS environment variable.
How It Compares to Telescope and Debugbar
| Tool | Storage | Scope | History | |---|---|---|---| | Laravel Telescope | Database | Requests, jobs, mail, cache, and more | Yes | | Laravel Debugbar | In-page toolbar | Timing and queries for current response | No | | Laravel Time Machine | Flat JSON files | Lifecycle timing and queries only | Yes (last 100) |
Time Machine sits between the two: it keeps a browsable history like Telescope but collects only lifecycle timing and query data, stored in flat files. If you need full application monitoring, Telescope remains the better fit. If you want to profile exactly where individual requests spend their time, Time Machine is purpose-built for that.
Installation
The package supports Laravel 8 through 13. Install via Composer — auto-discovery handles 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
Real Takeaways
- Pinpoint slow lifecycle phases (middleware, routing, controller) with millisecond precision.
- Capture and flag slow SQL queries without touching your database schema.
- Add custom spans around external API calls or heavy computations in seconds.
- Zero-migration setup keeps the profiler lightweight and portable.
- Debug-only default means no accidental performance overhead in production.
Source: Laravel Time Machine: A Request Lifecycle Profiler — Laravel News