PHPackages                             matchory/laravel-server-timing - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. matchory/laravel-server-timing

ActiveLibary[Logging &amp; Monitoring](/categories/logging)

matchory/laravel-server-timing
==============================

Add Server-Timing header information from within your Laravel apps.

1.3.3(3mo ago)112.9k—0.8%1MITPHPPHP ^8.2CI passing

Since Sep 20Pushed 3mo agoCompare

[ Source](https://github.com/matchory/laravel-server-timing)[ Packagist](https://packagist.org/packages/matchory/laravel-server-timing)[ Docs](https://github.com/matchory/laravel-server-timing)[ RSS](/packages/matchory-laravel-server-timing/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (11)Used By (1)

Laravel Server Timings
======================

[](#laravel-server-timings)

[![Latest Version on Packagist](https://camo.githubusercontent.com/20b81877017007eeaf6fdc5e607a7beca9b646f22355c7ed665c049b3617b2e9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617463686f72792f6c61726176656c2d7365727665722d74696d696e672e7376673f7374796c653d666c6174)](https://packagist.org/packages/matchory/laravel-server-timing)[![Build Status](https://github.com/matchory/laravel-server-timing/actions/workflows/tests.yaml/badge.svg)](https://github.com/matchory/laravel-server-timing/actions/workflows/tests.yaml/badge.svg)[![Total Downloads](https://camo.githubusercontent.com/c32723049cb9f0987d69944a6fad6a073644bde571cbeb54f3b8d2a9b3ff6073/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617463686f72792f6c61726176656c2d7365727665722d74696d696e672e7376673f7374796c653d666c6174)](https://packagist.org/packages/matchory/laravel-server-timing)[![Laravel Octane Compatible](https://camo.githubusercontent.com/70359a356da237cd29561bc5d0bb80baae775b5ff62f288ed324755382858342/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2532304f6374616e652d436f6d70617469626c652d737563636573733f7374796c653d666c6174266c6f676f3d6c61726176656c)](https://github.com/laravel/octane)

> Add Server-Timing header information from within your Laravel apps.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require matchory/laravel-server-timing
```

Usage
-----

[](#usage)

To add server-timing header information, you need to add the `\Matchory\ServerTiming\Middleware\ServerTimingMiddleware::class,` middleware to your HTTP Kernel. In order to get the most accurate results, put the middleware as the first one to load in the middleware stack.

By default, the middleware measures only three things, to keep it as light-weight as possible:

- Bootstrap (time before the middleware gets called)
- Application time (time to get a response within the app)
- Total (total time before sending out the response)

Once the package is successfully installed, you can see your timing information in the developer tools of your browser. Here's an example from Chrome: [![image](https://user-images.githubusercontent.com/40676515/73973252-d831a980-48e7-11ea-88fc-a606fd5b758a.png)](https://user-images.githubusercontent.com/40676515/73973252-d831a980-48e7-11ea-88fc-a606fd5b758a.png)

Enabling automatic database timing
----------------------------------

[](#enabling-automatic-database-timing)

To enable database timing, you have to options built-in that you can enable via the configuration file:

- `measure_database`: Measure total database timing. This will track the total time spent in database queries.
- `measure_queries`: Measure database timing per query. This will track the time spent in each individual query and add them as individual metrics.

> **Note:** If you have many queries, this may result in significantly large headers. Some web servers, like nginx, will bail if the headers grow too large. Review the manual for your web server to adjust these limits, if necessary.

Adding additional measurements
------------------------------

[](#adding-additional-measurements)

If you want to provide additional measurements, you can use the start and stop methods. If you do not explicitly stop a measured event, the event will automatically be stopped once the middleware receives your response. This can be useful if you want to measure the time your Blade views take to compile.

```
ServerTiming::start('Running expensive task');

// do something

ServerTiming::stop('Running expensive task');
```

If you already know the exact time that you want to set as the measured time, you can use the `setDuration` method. The duration should be set as milliseconds:

```
ServerTiming::setDuration('Running expensive task', 1_200);
```

In addition to providing milliseconds as the duration, you can also pass a callable that will be measured instead:

```
ServerTiming::setDuration('Running expensive task', function() {
    sleep(5);
});
```

Adding textual information
--------------------------

[](#adding-textual-information)

You can also use the Server-Timing middleware to only set textual information without providing a duration.

Publishing configuration file
-----------------------------

[](#publishing-configuration-file)

The configuration file could be published using: `php artisan vendor:publish --tag=server-timing-config`

You can disable the middleware changing the `timing.enabled` configuration to false.

```
ServerTiming::addMetric("User: {$user->id}");
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Testing

[](#testing)

To run unit tests, use the following command:

```
composer test
```

You can also run the type checks using the following command:

```
composer analyze
```

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

### Credits

[](#credits)

- [Moritz Friedrich](https://github.com/radiergummi)
- [Marcel Pociot](https://github.com/mpociot)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance82

Actively maintained with recent releases

Popularity28

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 56.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~138 days

Recently: every ~151 days

Total

10

Last Release

93d ago

PHP version history (2 changes)1.0.0PHP ^8.1

1.1.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/aa633f25468b1a85e85646d55aa16c39d04e163e92744d0a7c2a694dbcafc3e1?d=identicon)[Radiergummi](/maintainers/Radiergummi)

---

Top Contributors

[![Radiergummi](https://avatars.githubusercontent.com/u/6115429?v=4)](https://github.com/Radiergummi "Radiergummi (32 commits)")[![mpociot](https://avatars.githubusercontent.com/u/804684?v=4)](https://github.com/mpociot "mpociot (11 commits)")[![binaryk](https://avatars.githubusercontent.com/u/6833714?v=4)](https://github.com/binaryk "binaryk (6 commits)")[![mmachatschek](https://avatars.githubusercontent.com/u/10237069?v=4)](https://github.com/mmachatschek "mmachatschek (2 commits)")[![intellow](https://avatars.githubusercontent.com/u/40676515?v=4)](https://github.com/intellow "intellow (1 commits)")[![jetwes](https://avatars.githubusercontent.com/u/1346373?v=4)](https://github.com/jetwes "jetwes (1 commits)")[![sarfraznawaz2005](https://avatars.githubusercontent.com/u/201788?v=4)](https://github.com/sarfraznawaz2005 "sarfraznawaz2005 (1 commits)")[![spekulatius](https://avatars.githubusercontent.com/u/8433587?v=4)](https://github.com/spekulatius "spekulatius (1 commits)")[![sschlein](https://avatars.githubusercontent.com/u/2911113?v=4)](https://github.com/sschlein "sschlein (1 commits)")[![drbyte](https://avatars.githubusercontent.com/u/404472?v=4)](https://github.com/drbyte "drbyte (1 commits)")

---

Tags

laravelperformancelaravel-packagelaravel-server-timingServer-Timingmatchory

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/matchory-laravel-server-timing/health.svg)

```
[![Health](https://phpackages.com/badges/matchory-laravel-server-timing/health.svg)](https://phpackages.com/packages/matchory-laravel-server-timing)
```

###  Alternatives

[beyondcode/laravel-server-timing

Add Server-Timing header information from within your Laravel apps.

5712.0M1](/packages/beyondcode-laravel-server-timing)[jackwh/laravel-new-relic

Monitor your Laravel application performance with New Relic

112827.2k](/packages/jackwh-laravel-new-relic)[kitloong/laravel-app-logger

Laravel log for your application

101.2M8](/packages/kitloong-laravel-app-logger)[scoutapp/scout-apm-laravel

Scout Application Performance Monitoring Agent - https://scoutapm.com

23831.3k](/packages/scoutapp-scout-apm-laravel)[kevincobain2000/laravel-alert-notifications

Alert notifications of exceptions from your laravel application

2621.1k](/packages/kevincobain2000-laravel-alert-notifications)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
