Laravel Time Machine: Request Lifecycle Profiler | Mohamed Said        [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://www.msaied.com) [ Home ](https://www.msaied.com) [ Projects ](https://www.msaied.com/projects) [ Articles  ](https://www.msaied.com/articles) [ Certificates ](https://www.msaied.com/certificates) [ Contact ](https://www.msaied.com#contact-section) 

       [  ](https://github.com/EG-Mohamed)       

 [ Home ](https://www.msaied.com) [ Projects ](https://www.msaied.com/projects) [ Articles ](https://www.msaied.com/articles) [ Certificates ](https://www.msaied.com/certificates) [ Contact ](https://www.msaied.com#contact-section) 

  [ home ](https://www.msaied.com)    [ articles ](https://www.msaied.com/articles)    Laravel Time Machine: Profile Every Stage of a Request Lifecycle        On this page       1. [  What Is Laravel Time Machine? ](#what-is-laravel-time-machine)
2. [  Key Features at a Glance ](#key-features-at-a-glance)
3. [  The Timeline Dashboard ](#the-timeline-dashboard)
4. [  Custom Instrumentation with the TimeMachine Facade ](#custom-instrumentation-with-the-timemachine-facade)
5. [  Storage Without a Database ](#storage-without-a-database)
6. [  How It Compares to Telescope and Debugbar ](#how-it-compares-to-telescope-and-debugbar)
7. [  Installation ](#installation)
8. [  Real Takeaways ](#real-takeaways)

  ![Laravel Time Machine: Profile Every Stage of a Request Lifecycle](https://cdn.msaied.com/453/308c1bf5c3ea88a09ccda212f98bc409.png)

 [  Laravel ](https://www.msaied.com/articles?category=laravel) [  Composer Pacakge ](https://www.msaied.com/articles?category=composer-pacakge)  #Laravel   #Performance Profiling   #Developer Tools   #Composer Package   #Debugging  

 Laravel Time Machine: Profile Every Stage of a Request Lifecycle 
==================================================================

     20 Jul 2026      3 min read    ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said  

       Table of contents

1. [  01   What Is Laravel Time Machine?  ](#what-is-laravel-time-machine)
2. [  02   Key Features at a Glance  ](#key-features-at-a-glance)
3. [  03   The Timeline Dashboard  ](#the-timeline-dashboard)
4. [  04   Custom Instrumentation with the TimeMachine Facade  ](#custom-instrumentation-with-the-timemachine-facade)
5. [  05   Storage Without a Database  ](#storage-without-a-database)
6. [  06   How It Compares to Telescope and Debugbar  ](#how-it-compares-to-telescope-and-debugbar)
7. [  07   Installation  ](#installation)
8. [  08   Real Takeaways  ](#real-takeaways)

 What Is Laravel Time Machine?
-----------------------------

[Laravel Time Machine](https://github.com/JaydeepGadhiya/laravel-timemachine) 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 `terminate` step.
- **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_DEBUG` so 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:

```php
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:

```bash
composer require jaydeep/laravel-time-machine

```

Publishing the config file is optional:

```bash
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](https://laravel-news.com/laravel-time-machine-a-request-lifecycle-profiler)*

 Found this useful?

          [  ](https://twitter.com/intent/tweet?url=https%3A%2F%2Fwww.msaied.com%2Farticles%2Flaravel-time-machine-profile-every-stage-of-a-request-lifecycle&text=Laravel+Time+Machine%3A+Profile+Every+Stage+of+a+Request+Lifecycle) [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fwww.msaied.com%2Farticles%2Flaravel-time-machine-profile-every-stage-of-a-request-lifecycle) 

 Frequently Asked Questions 
----------------------------

  3 questions  

     Q01  Does Laravel Time Machine require a database or migrations?        No. Profiles are stored as plain JSON files in `storage/time-machine`. There are no database tables or migrations required, and data never leaves your server. 

      Q02  How is Laravel Time Machine different from Laravel Telescope?        Telescope monitors many application concerns (requests, jobs, mail, cache, and more) and stores data in a database. Time Machine focuses exclusively on request lifecycle timing and SQL queries, stores data in flat files, and presents results on a Gantt-style timeline — making it lighter and more focused for per-request performance profiling. 

      Q03  Is Laravel Time Machine safe to leave installed in production?        By default the profiler follows `APP_DEBUG`, so it is inactive when `APP_DEBUG=false`. You can explicitly enable or disable it regardless of the debug setting via the package configuration. 

  Continue reading

 More Articles 
---------------

 [ View all    ](https://www.msaied.com/articles) 

 [ ![Modular Monolith in Laravel: Enforcing Bounded Contexts Without a Microservices Tax](https://cdn.msaied.com/451/014ea4597c12e3ba1ce7a4f4a33d299e.png) laravel architecture ddd 

### Modular Monolith in Laravel: Enforcing Bounded Contexts Without a Microservices Tax

Learn how to carve a Laravel application into cohesive bounded contexts using modules, internal contracts, and...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 21 Jul 2026     3 min read  

  Read    

 ](https://www.msaied.com/articles/modular-monolith-in-laravel-enforcing-bounded-contexts-without-a-microservices-tax-3) [ ![DDD Value Objects and DTOs in Laravel Without the Bloat](https://cdn.msaied.com/450/41688537085b86f102fd8c219a35319f.png) laravel ddd php 

### DDD Value Objects and DTOs in Laravel Without the Bloat

Learn how to implement domain-driven value objects and data transfer objects in Laravel using PHP 8.3 readonly...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 21 Jul 2026     1 min read  

  Read    

 ](https://www.msaied.com/articles/ddd-value-objects-and-dtos-in-laravel-without-the-bloat) [ ![Laravel + Python FastAPI: Image OCR Demo](https://cdn.msaied.com/447/5f3d87146fbf19957973cbc88c6c0155.png) Laravel Python FastAPI 

### Laravel + Python FastAPI: Image OCR Demo

Learn how to call a Python image OCR script from Laravel using FastAPI as the bridge. This premium tutorial wa...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 20 Jul 2026     3 min read  

  Read    

 ](https://www.msaied.com/articles/laravel-python-fastapi-image-ocr-demo) 

   [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://www.msaied.com)Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

Explore

- [Home](https://www.msaied.com)
- [Projects](https://www.msaied.com/projects)
- [Articles](https://www.msaied.com/articles)
- [Certificates](https://www.msaied.com/certificates)
- [Contact](https://www.msaied.com#contact-section)

Connect

- [   hello@msaied.com ](mailto:hello@msaied.com)
- [   +20 109 461 9204 ](tel:+201094619204)

© 2026 Mohamed Said. All rights reserved.

 [  ](https://github.com/EG-Mohamed) [  ](https://www.linkedin.com/in/msaiedm/) [  ](https://wa.me/201094619204) [  ](mailto:hello@msaied.com) [  ](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
