Skip to content

Commit 3b5f40f

Browse files
committed
Support for Laravel 11
1 parent 9b25380 commit 3b5f40f

File tree

4 files changed

+29
-46
lines changed

4 files changed

+29
-46
lines changed

.scrutinizer.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

README.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Laravel Server Timings
22

33
[![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)
4-
[![Build Status](https://img.shields.io/travis/beyondcode/laravel-server-timing/master.svg?style=flat-square)](https://travis-ci.org/beyondcode/laravel-server-timing)
5-
[![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)
64
[![Total Downloads](https://img.shields.io/packagist/dt/beyondcode/laravel-server-timing.svg?style=flat-square)](https://packagist.org/packages/beyondcode/laravel-server-timing)
75

86
Add Server-Timing header information from within your Laravel apps.
@@ -20,6 +18,29 @@ composer require beyondcode/laravel-server-timing
2018
To add server-timing header information, you need to add the `\BeyondCode\ServerTiming\Middleware\ServerTimingMiddleware::class,` middleware to your HTTP Kernel.
2119
In order to get the most accurate results, put the middleware as the first one to load in the middleware stack.
2220

21+
### Laravel 11
22+
`bootstrap/app.php`
23+
```php
24+
return Application::configure(basePath: dirname(__DIR__))
25+
// ...
26+
->withMiddleware(function (Middleware $middleware) {
27+
$middleware->prepend(\BeyondCode\ServerTiming\Middleware\ServerTimingMiddleware::class);
28+
})
29+
// ...
30+
->create();
31+
```
32+
33+
### Laravel 10 and below
34+
`app/Http/Kernel.php`
35+
```php
36+
class Kernel extends HttpKernel
37+
{
38+
protected $middleware = [
39+
\BeyondCode\ServerTiming\Middleware\ServerTimingMiddleware::class,
40+
// ...
41+
];
42+
```
43+
2344
By default, the middleware measures only three things, to keep it as light-weight as possible:
2445

2546
- Bootstrap (time before the middleware gets called)
@@ -35,9 +56,12 @@ Once the package is successfully installed, you can see your timing information
3556
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.
3657

3758
```php
59+
use BeyondCode\ServerTiming\Facades\ServerTiming;
60+
3861
ServerTiming::start('Running expensive task');
3962

40-
// do something
63+
// Take a nap
64+
sleep(5);
4165

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

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
],
1818
"require": {
1919
"php": "^7.2|^8.0",
20-
"illuminate/support": "5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0",
21-
"symfony/stopwatch": "^4.0|^5.0|^6.0"
20+
"illuminate/support": "5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
21+
"symfony/stopwatch": "^4.0|^5.0|^6.0|^7.0"
2222
},
2323
"require-dev": {
2424
"orchestra/testbench": "^4.6|^5.0|^6.0|^8.0",

0 commit comments

Comments
 (0)