PHPackages                             hocvt/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. hocvt/laravel-server-timing

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

hocvt/laravel-server-timing
===========================

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

v12.0.0(1y ago)12.2k↓50%MITPHPPHP ^7.2|^8.0

Since Feb 3Pushed 1y agoCompare

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

READMEChangelog (3)Dependencies (4)Versions (8)Used By (0)

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

[](#laravel-server-timings)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a644ed8e07e37a343f7338b3f725e11cfbfeb42a31875839c2b662f527e91b2c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6265796f6e64636f64652f6c61726176656c2d7365727665722d74696d696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beyondcode/laravel-server-timing)[![Total Downloads](https://camo.githubusercontent.com/745d6af4aeedb6c6fd0284ddd76131df143932061d2a9cc6b361cd6254256e5e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6265796f6e64636f64652f6c61726176656c2d7365727665722d74696d696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beyondcode/laravel-server-timing)

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

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

[](#installation)

You can install the package via composer:

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

Usage
-----

[](#usage)

To add server-timing header information, you need to add the `\BeyondCode\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.

### Laravel 11

[](#laravel-11)

`bootstrap/app.php`

```
return Application::configure(basePath: dirname(__DIR__))
    // ...
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->prepend(\BeyondCode\ServerTiming\Middleware\ServerTimingMiddleware::class);
    })
    // ...
    ->create();
```

### Laravel 10 and below

[](#laravel-10-and-below)

`app/Http/Kernel.php`

```
class Kernel extends HttpKernel
{
    protected $middleware = [
        \BeyondCode\ServerTiming\Middleware\ServerTimingMiddleware::class,
        // ...
    ];
```

---

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:

[![CleanShot 2024-03-18 at 13 48 53@2x](https://private-user-images.githubusercontent.com/26432041/313688460-adea40e4-5c34-4aee-9fb7-ad6bac40addc.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzIyNzc0MTQsIm5iZiI6MTc3MjI3NzExNCwicGF0aCI6Ii8yNjQzMjA0MS8zMTM2ODg0NjAtYWRlYTQwZTQtNWMzNC00YWVlLTlmYjctYWQ2YmFjNDBhZGRjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAyMjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMjI4VDExMTE1NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgxOWE4NTc0YmZmMTU1ZmUxZjU0OThhZWUwNDVlN2NmMzJhNWQ5NWQyZThkYjkwMzBmNDc1NWMzYTYxNzg5ODImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Yq3ELE7EcFsm3V6k4lMZrSAWvK2PtrIjDpFv1m46XGw)](https://private-user-images.githubusercontent.com/26432041/313688460-adea40e4-5c34-4aee-9fb7-ad6bac40addc.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzIyNzc0MTQsIm5iZiI6MTc3MjI3NzExNCwicGF0aCI6Ii8yNjQzMjA0MS8zMTM2ODg0NjAtYWRlYTQwZTQtNWMzNC00YWVlLTlmYjctYWQ2YmFjNDBhZGRjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAyMjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMjI4VDExMTE1NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgxOWE4NTc0YmZmMTU1ZmUxZjU0OThhZWUwNDVlN2NmMzJhNWQ5NWQyZThkYjkwMzBmNDc1NWMzYTYxNzg5ODImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Yq3ELE7EcFsm3V6k4lMZrSAWvK2PtrIjDpFv1m46XGw)

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.

```
use BeyondCode\ServerTiming\Facades\ServerTiming;

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

// Take a nap
sleep(5);

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

[![CleanShot 2024-03-18 at 13 51 56@2x](https://private-user-images.githubusercontent.com/26432041/313688611-47e9e692-2bce-4449-a7ea-966fa4701cdb.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzIyNzc0MTQsIm5iZiI6MTc3MjI3NzExNCwicGF0aCI6Ii8yNjQzMjA0MS8zMTM2ODg2MTEtNDdlOWU2OTItMmJjZS00NDQ5LWE3ZWEtOTY2ZmE0NzAxY2RiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAyMjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMjI4VDExMTE1NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTUwNjkyN2ViZTllY2ZmZWRjZWRmOTI4ZWQwYWIzYzhhZmZhYTZjODQ2NGJkYzM1YWU2YmM5ZjkzNjEyYTBiOGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.B49ptfz6cw_9jlzvarIyE90Eq1b5Lik2Jjl_PPTMKbg)](https://private-user-images.githubusercontent.com/26432041/313688611-47e9e692-2bce-4449-a7ea-966fa4701cdb.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzIyNzc0MTQsIm5iZiI6MTc3MjI3NzExNCwicGF0aCI6Ii8yNjQzMjA0MS8zMTM2ODg2MTEtNDdlOWU2OTItMmJjZS00NDQ5LWE3ZWEtOTY2ZmE0NzAxY2RiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAyMjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMjI4VDExMTE1NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTUwNjkyN2ViZTllY2ZmZWRjZWRmOTI4ZWQwYWIzYzhhZmZhYTZjODQ2NGJkYzM1YWU2YmM5ZjkzNjEyYTBiOGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.B49ptfz6cw_9jlzvarIyE90Eq1b5Lik2Jjl_PPTMKbg)

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', 1200);
```

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.

```
ServerTiming::addMetric('User: '.$user->id);
```

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 by changing the `timing.enabled` configuration to false or adding `SERVER_TIMING_ENABLED=false` to your `.env` file.

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

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

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

[](#contributing)

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

### Security

[](#security)

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

Credits
-------

[](#credits)

- [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

41

—

FairBetter than 89% of packages

Maintenance50

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~320 days

Recently: every ~423 days

Total

7

Last Release

368d ago

Major Versions

v1.4.0 → v10.0.02023-06-19

v10.0.0 → v12.0.02025-05-08

PHP version history (3 changes)1.0.0PHP ^7.3

1.1.0PHP ^7.2

1.3.0PHP ^7.2|^8.0

### Community

Maintainers

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

---

Top Contributors

[![mpociot](https://avatars.githubusercontent.com/u/804684?v=4)](https://github.com/mpociot "mpociot (13 commits)")[![mechelon](https://avatars.githubusercontent.com/u/26432041?v=4)](https://github.com/mechelon "mechelon (11 commits)")[![binaryk](https://avatars.githubusercontent.com/u/6833714?v=4)](https://github.com/binaryk "binaryk (6 commits)")[![vuthaihoc](https://avatars.githubusercontent.com/u/2509658?v=4)](https://github.com/vuthaihoc "vuthaihoc (3 commits)")[![adamhopkinson](https://avatars.githubusercontent.com/u/1493635?v=4)](https://github.com/adamhopkinson "adamhopkinson (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![mmachatschek](https://avatars.githubusercontent.com/u/10237069?v=4)](https://github.com/mmachatschek "mmachatschek (2 commits)")[![drbyte](https://avatars.githubusercontent.com/u/404472?v=4)](https://github.com/drbyte "drbyte (1 commits)")[![intellow](https://avatars.githubusercontent.com/u/40676515?v=4)](https://github.com/intellow "intellow (1 commits)")[![wit3](https://avatars.githubusercontent.com/u/5450259?v=4)](https://github.com/wit3 "wit3 (1 commits)")[![hms5232](https://avatars.githubusercontent.com/u/43672033?v=4)](https://github.com/hms5232 "hms5232 (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)")[![jetwes](https://avatars.githubusercontent.com/u/1346373?v=4)](https://github.com/jetwes "jetwes (1 commits)")[![johnwc](https://avatars.githubusercontent.com/u/2798441?v=4)](https://github.com/johnwc "johnwc (1 commits)")

---

Tags

beyondcodelaravel-server-timing

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/hocvt-laravel-server-timing/health.svg)](https://phpackages.com/packages/hocvt-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)[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[kitloong/laravel-app-logger

Laravel log for your application

101.2M8](/packages/kitloong-laravel-app-logger)[label84/laravel-auth-log

Log user authentication actions in Laravel.

3654.0k](/packages/label84-laravel-auth-log)[shaffe/laravel-mail-log-channel

A package to support logging via email in Laravel

1286.2k](/packages/shaffe-laravel-mail-log-channel)

PHPackages © 2026

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