From 3b5f40fdc5453d6fbdfff4f2b71c280e22b131d7 Mon Sep 17 00:00:00 2001 From: Di Date: Mon, 18 Mar 2024 13:58:35 +0100 Subject: [PATCH] Support for Laravel 11 --- .scrutinizer.yml | 19 ------------------- .travis.yml | 22 ---------------------- README.md | 30 +++++++++++++++++++++++++++--- composer.json | 4 ++-- 4 files changed, 29 insertions(+), 46 deletions(-) delete mode 100644 .scrutinizer.yml delete mode 100644 .travis.yml diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index df16b68..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,19 +0,0 @@ -filter: - excluded_paths: [tests/*] - -checks: - php: - remove_extra_empty_lines: true - remove_php_closing_tag: true - remove_trailing_whitespace: true - fix_use_statements: - remove_unused: true - preserve_multiple: false - preserve_blanklines: true - order_alphabetically: true - fix_php_opening_tag: true - fix_linefeed: true - fix_line_ending: true - fix_identation_4spaces: true - fix_doc_comments: true - diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7e699d4..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: php - -php: - - 7.2 - - 7.3 - - 7.4 - - nightly - -env: - matrix: - - COMPOSER_FLAGS="--prefer-lowest" - - COMPOSER_FLAGS="" - -before_script: - - travis_retry composer self-update - - travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source - -script: - - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover - -after_script: - - php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover diff --git a/README.md b/README.md index ad0b585..8653eb5 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # Laravel Server Timings [![Latest Version on Packagist](https://img.shields.io/packagist/v/beyondcode/laravel-server-timing.svg?style=flat-square)](https://packagist.org/packages/beyondcode/laravel-server-timing) -[![Build Status](https://img.shields.io/travis/beyondcode/laravel-server-timing/master.svg?style=flat-square)](https://travis-ci.org/beyondcode/laravel-server-timing) -[![Quality Score](https://img.shields.io/scrutinizer/g/beyondcode/laravel-server-timing.svg?style=flat-square)](https://scrutinizer-ci.com/g/beyondcode/laravel-server-timing) [![Total Downloads](https://img.shields.io/packagist/dt/beyondcode/laravel-server-timing.svg?style=flat-square)](https://packagist.org/packages/beyondcode/laravel-server-timing) Add Server-Timing header information from within your Laravel apps. @@ -20,6 +18,29 @@ composer require beyondcode/laravel-server-timing 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 +`bootstrap/app.php` +```php +return Application::configure(basePath: dirname(__DIR__)) + // ... + ->withMiddleware(function (Middleware $middleware) { + $middleware->prepend(\BeyondCode\ServerTiming\Middleware\ServerTimingMiddleware::class); + }) + // ... + ->create(); +``` + +### Laravel 10 and below +`app/Http/Kernel.php` +```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) @@ -35,9 +56,12 @@ Once the package is successfully installed, you can see your timing information 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. ```php +use BeyondCode\ServerTiming\Facades\ServerTiming; + ServerTiming::start('Running expensive task'); -// do something +// Take a nap +sleep(5); ServerTiming::stop('Running expensive task'); ``` diff --git a/composer.json b/composer.json index 51bf1cb..907ea8d 100644 --- a/composer.json +++ b/composer.json @@ -17,8 +17,8 @@ ], "require": { "php": "^7.2|^8.0", - "illuminate/support": "5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0", - "symfony/stopwatch": "^4.0|^5.0|^6.0" + "illuminate/support": "5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", + "symfony/stopwatch": "^4.0|^5.0|^6.0|^7.0" }, "require-dev": { "orchestra/testbench": "^4.6|^5.0|^6.0|^8.0",