sandermuller / stopwatch
Lightweight profiler for PHP and Laravel. Add checkpoints, measure closures, track queries and memory, and surface results as HTML, Server-Timing headers, log entries, or Debugbar timelines.
Requires
- php: ^8.3
- illuminate/collections: ^12.0|^13.0
- illuminate/contracts: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
- nesbot/carbon: ^2|^3.10.3
- spatie/laravel-package-tools: ^1.92.7
- symfony/var-dumper: ^7.3.3|^8.0
Requires (Dev)
- driftingly/rector-laravel: ^2.3
- fakerphp/faker: ^1.24
- fruitcake/laravel-debugbar: ^4.2
- illuminate/database: ^12.0|^13.0
- larastan/larastan: ^3.9
- laravel/boost: ^2.0||^3.0
- laravel/pao: ^1.0
- laravel/pint: ^1.24
- nunomaduro/collision: ^8.8.2
- orchestra/testbench: ^10.6|^11.0
- phpstan/extension-installer: ^1.4.3
- phpstan/phpstan-deprecation-rules: ^2.0.3
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0.6
- phpunit/phpunit: ^11.0||^12.0
- rector/rector: ^2.1.7
- rector/type-perfect: ^2.1
- sandermuller/boost-skills: ^2.33.0
- sandermuller/package-boost-laravel: ^1.1
- spaze/phpstan-disallowed-calls: ^4.6
- stolt/lean-package-validator: ^5.7.1 || ^6.0.0
- symplify/phpstan-extensions: ^12.0.1
- tomasvotruba/cognitive-complexity: ^1.0
- tomasvotruba/type-coverage: >=2.2.0 <2.2.2
Suggests
- fruitcake/laravel-debugbar: Display stopwatch checkpoints as a timeline in Debugbar
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-10 06:28:25 UTC
README
A lightweight profiler for PHP and Laravel. Add checkpoints, measure closures, track queries, memory and outbound HTTP, and see where the time goes. Use it when a request, command or job feels slow and an APM is more than you need. It runs in production, in tests and in CI.
PHP 8.3+ · Laravel 12.x / 13.x
Installation
composer require sandermuller/stopwatch
php artisan vendor:publish --tag=stopwatch-config # optional
Quick start
stopwatch()->withQueryTracking()->start(); $users = User::all(); stopwatch()->checkpoint('Load users'); $orders = Order::where('status', 'pending')->get(); stopwatch()->checkpoint('Load orders'); stopwatch()->toLog('Profile:'); // Profile: // [3ms / 3ms] Load users (queries=1) // [12ms / 15ms] Load orders (queries=1) // Total: 15ms
checkpoint() starts the stopwatch on its own, so start() is only needed to reset an earlier run.
Render it as a self-contained HTML card instead:
@stopwatch
Documentation
Published at https://sandermuller.github.io/Stopwatch/.
- Why Stopwatch?: what it answers, and when an APM is the better tool
- Installation · Getting started · Checkpoints · Query, memory and HTTP tracking
- HTML report · Profiler toolbar · Server-Timing and Debugbar
- Persistent run log · Crash diagnostics
- Slow-run notifications · AI assistant integration · Standalone PHP
- Configuration · API
The sources are in docs/.
Testing
composer test
Changelog
CHANGELOG lists the recent changes.
Contributing
CONTRIBUTING covers local setup and the pull-request process.
Security vulnerabilities
Report a vulnerability through the security policy rather than a public issue.
Credits
License
The MIT License (MIT). Please see the License File for more information.
