code-tieumomo/laravel-server-timing

A simple implementation of Server-Timing in Laravel.

v0.1.0 2024-09-21 17:45 UTC

This package is auto-updated.

Last update: 2024-12-21 18:19:43 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides a simple implementation of the Server-Timing header in Laravel.

Installation

You can install the package via composer:

composer require code-tieumomo/laravel-server-timing

Usage

return response()->json([])
    ->serverTiming([
        'bootstrap' => [
            'desc' => 'Bootstrap',
            'dur' => 32.552003860474,
        ],
        'app' => [
            'desc' => 'App',
            'dur' => 8,
        ],
        'total' => [
            'desc' => 'Total',
            'dur' => 41.576147079468,
        ],
    ]);

Or if you want to return a view:

return response(view('work-orders.show', compact('workOrder')))
    ->serverTiming([
        'bootstrap' => [
            'desc' => 'Bootstrap',
            'dur' => 32.552003860474,
        ],
        'app' => [
            'desc' => 'App',
            'dur' => 8,
        ],
        'total' => [
            'desc' => 'Total',
            'dur' => 41.576147079468,
        ],
    ]);

Image

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.