olgunozoktas/laravel-page-performance
Larablocks Analysis
olgunozoktas/laravel-page-performance works with Laravel 12 and 13 (latest release v0.2.0, Nov 17, 2026).
Recommendation checks
PromisingPromising: maintained and up to date, meets 2 of 4 checks; not yet widely used.
- Works with Laravel 13, the current version
- Released in the last 12 months (Nov 17, 2026)
- 33 downloads a month (needs 10,000)
- 0 GitHub stars (needs 100)
State
Actively maintained- Last stable release: Nov 17, 2026.
- 6 releases in the last 12 months.
- First released: Aug 26, 2026.
- Monthly downloads: 33.
- 1 open issue on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Nov 30, 2026.
| Install | |
|---|---|
composer require olgunozoktas/laravel-page-performance |
|
| Latest Version: | v0.2.0 |
| PHP: | ^8.3 |
| Laravel: | 12 · 13 |
| License: | MIT |
| Last Updated: | Nov 17, 2026 |
| Links: | GitHub · Packagist |
Laravel Page Performance
Measure what every page costs, fix the bottlenecks, and compile anonymous Blade components in one package.
olgunozoktas/laravel-page-performance combines four layers in one zero-dependency Laravel package:
- Page and request profiler (
perf:pages,perf:requests,perf:doctor,perf:vitals): warms the process, measures N in-process requests, and diagnoses SQL queries & read-onlyEXPLAINplans (--queries,--explain), Eloquent hydration & lazy-loading N+1s, Cache hit ratios & duplicate reads, JS/CSS bundle budgets, Livewire snapshots, outbound HTTP calls, SEO defects, Core Web Vitals (LCP/INP/CLS), and real-user p75 RUM beacons (@perfVitals) — ending in a file and a line. - Built-in Blade optimizer (
PagePerformance::optimize(),@perf,@blaze,@unblaze,@perfCache): accelerates flat parent.blade.phpechoes (EncodedHtmlEscaper), compiles anonymous<x-...>components into OPcache PHP functions, adds bounded request memoization, safe CSRF/Livewire-guarded@perfCachefragment caching, and compile-time static folding with zero production profiling overhead. - Instant-page HTTP helpers (
@perfSpeculationRules,AddPerformanceHints,AddWeakEtag,DeduplicateSvgIcons): adds safe Speculation Rules prefetching, automatic LCP Early Hints (Link: rel=preload), RFC 9110 Weak ETag304 Not Modified, guard-railed publicCache-Control, and inline SVG sprite deduplication. - Static PHP, Blade, Livewire, Alpine, and CWV auditor (
perf:audit,perf:blade-plan): scans PHP and Blade files for 29 performance anti-patterns (including plain-PHP loops, unbounded->get(), and queue jobs missing#[WithoutRelations]) and classifies anonymous components in pure PHP, with optional multi-core Rust acceleration (rust/perf-audit/+ prebuilt macOS/Linux release binaries).
php artisan perf:pages walks every GET route whose parameters are known, warms the process,
measures N in-process requests, and prints a table ordered worst-first where
every row carries a diagnosis rather than a number.
+-----------------------------+------+--------+------+------+------+----+-----+------+------+-------------------------------------------+
| page | ms | spread | cold | db | lw | q | dup | snap | html | diagnosis |
+-----------------------------+------+--------+------+------+------+----+-----+------+------+-------------------------------------------+
| board.home | 68.5 | 2% | 71 | 34.9 | 24.4 | 18 | 2 | 727 | 260K | repeated-query · db-bound · payload-heavy |
| board.directory | 32.6 | 11% | 39 | 13.5 | 12.5 | 8 | 1 | 277 | 153K | repeated-query · payload-heavy |
| board.rules | 15.5 | 4% | 16 | 6.9 | 3.0 | 5 | 1 | 273 | 69K | repeated-query |
+-----------------------------+------+--------+------+------+------+----+-----+------+------+-------------------------------------------+
board.home / repeated-query · db-bound · payload-heavy
x2 select count(*) as "aggregate" from "listings" where "status" = ? and …
app/Boards/PublicPages/BoardHome.php:88
php artisan perf:requests does the same for the requests that you name: a
POST, an API write with a key and a JSON body, a JSON-RPC call. Each run is
rolled back (see Requests).
A table of milliseconds tells you which page is slowest. It does not tell you what to open. Every finding here ends in a file and a line.
Those route names are real. board.home, board.directory and
board.rules are pages of SeeRanks, the application
this package was written for and is measured against. Every number in this
README — the 150.4 ms cold request, the 287,831 bytes that arrive as 32,514, the
77 findings that group to 8 — came from a sweep of that codebase, not from a
benchmark written to make a point.
Install
From Packagist:
composer require olgunozoktas/laravel-page-performance
php artisan vendor:publish --tag=page-performance-config
Install as a regular dependency when you enable the built-in Blade optimizer, or with --dev if you only use the profiler and static auditor in local/CI. The runtime optimizer registers zero profiling listeners in production, and perf:pages and perf:requests refuse to run in production.
Livewire is optional. Without it you get every page-level metric, the Blade optimizer, HTML SEO/CWV checks, and perf:audit; with it you also get per-component Livewire render timing and snapshot payload bytes.
Included Capabilities
- Production Blade & HTML Runtime: parent
.blade.phpfastEncodedHtmlEscaperechoes (2.45xfaster flat Blade views), safe@perfCachefragment caching (CSRF/Livewire/CSP-nonce guarded), direct CV@propscompiler (noextract()), preamble hoisting, single-echo slotob_start()elision, zero-BladeSlotstring slots, multi-key baglessBladeAttributeRenderer, inline 1-prop scalar memo,View::share()parity, dynamic pass-through folding (autoSafeFold),@unblaze,FoldManifest, collection-freeBladeAttributeBag, single-file OPcache bundle (perf:blade:warm), compile-time HTML compaction (BladeWhitespaceCompactor),DeduplicateSvgIcons,AddPerformanceHints(withauto_early_hints),AddWeakEtag,@perfVitals, and Speculation Rules. - Profiling, Audits & Benchmarks:
perf:pages/perf:requests(--queries,--explain, Eloquent hydration & lazy-load tracking, Cache profiling, JS/CSS bundle budgets, extended LCP/INP/CLS checks),perf:doctor,perf:vitals,perf:benchmark(21 built-in benchmarks),perf:blade-parity,perf:blade-plan, 29-rule PHP/Rustperf:audit, and the unified Blade + SQL + Memory Flame-Chart Profiler (/_perf/profiler,perf:trace:*).
Performance: Previous Versions vs Now (v0.2.0 → v0.11.0)
Every release from v0.2.0 (stock Laravel Blade baseline) through v0.6.0 was benchmarked in isolation from its git tag on the same machine (PHP 8.4.28, opcache.enable_cli=1, Apple Silicon, 2026-12-01), followed by head-to-head hot-path benchmarks for v0.7.0 (2026-12-01), v0.8.0 (2026-12-02), v0.9.0 (2026-12-02), v0.10.0 (2026-12-02), and v0.11.0 (2026-12-03) with 100% byte-for-byte HTML parity across all rendering modes.
1. Blade Component Rendering Speed
Measured across 5,000 renders using getrusage() CPU time (min of 5 runs after warmup, opcache.enable_cli=1):
| Version & Mode | Badge (295,000 B HTML) |
Speedup vs Blade | Dynamic Card (821,670 B HTML) |
Speedup vs Blade | Key Optimization |
|---|---|---|---|---|---|
v0.2.0 Stock Laravel Blade |
430.89 ms |
1.0x (baseline) |
413.74 ms |
1.0x (baseline) |
Standard Blade view factory + ComponentAttributeBag |
v0.3.0 Compiled function (compile: true) |
46.77 ms |
9.2x (-89.1%) |
53.91 ms |
7.7x (-87.0%) |
First OPcache-friendly anonymous component PHP compiler |
v0.4.0 Zero-buffer + leaf fast-path |
41.18 ms |
10.5x (-90.4%) |
53.55 ms |
7.7x (-87.1%) |
Removes ob_start()/ltrim() on static starts + lean @props |
v0.5.0 Collection-free BladeAttributeBag |
25.60 ms |
16.8x (-94.1%) |
42.18 ms |
9.8x (-89.8%) |
Eliminates Illuminate\Support\Collection allocations per call |
v0.6.0 Compiled + stack elision |
25.72 ms |
16.8x (-94.0%) |
41.26 ms |
10.0x (-90.0%) |
Non-recursive call-site stack elision (-41.2% view bytes vs v0.5.0) |
v0.6.0 Bounded request memo (memo: true) |
9.59 ms |
44.9x (-97.8%) |
— | — | Zero-serialize() scalar memoKey + optional Octane persistent memo |
v0.6.0 Dynamic pass-through fold (autoSafeFold) |
— | — | 14.08 ms |
29.4x (-96.6%) |
Folds dynamic :id, :title, and $slot at compile time (2.9x vs compiled) |
v0.6.0 Static fold / auto-promoted memo |
0.78 ms |
552x (-99.8%) |
— | — | Zero-runtime static HTML (promoteStaticMemoToFold(true) promotes pure static memo calls) |
Runtime & Compiler Hot-Path Improvements (v0.7.0 → v0.8.0)
Measured on PHP 8.4 (opcache.enable_cli=1, median of 7 runs after warmup, 2026-12-02) with 100% byte-for-byte HTML parity:
| Workload | v0.7.0 |
v0.8.0 |
Speedup / Reduction | Key Optimization |
|---|---|---|---|---|
Paired leaf @props + static slot (5k) |
6.434 ms |
3.131 ms |
2.05x (-51.3%) |
Direct CV @props (no extract()), hoisted preamble, leaf @aware & ob_start() elision |
Self-closing leaf @props (5k) |
5.133 ms |
3.798 ms |
1.35x (-26.0%) |
Direct CV @props + hoisted BladeRuntime::instance() / function_exists() |
Paired card @props + merge() + {{ $slot }} (5k) |
17.165 ms |
10.746 ms |
1.60x (-37.4%) |
Single-echo slot ob_start() elision + zero-copy merge(['class' => ...]) fast-path |
| Memoized static inputs (5k) | 2.722 ms |
0.271 ms |
10.04x (-90.0%) |
Compile-time static memo key + direct memoStore->entries lookup |
| Memoized dynamic inputs (5k, 10 keys) | 2.542 ms |
2.116 ms |
1.20x (-16.8%) |
Single-call BladeRuntime::memoFetchFor() + hoisted preamble |
BladeWhitespaceCompactor (50 cards × 100) |
45.371 ms |
24.700 ms |
1.84x (-45.6%) |
PCRE2 first-letter trie + possessive lookahead + case-sensitive fast-path |
| Compiled PHP view size (200 paired tags) | 281,000 B |
98,296 B |
2.86x smaller (-65.0%) |
Template-level preamble hoisting + BladeRuntime::callObserved() |
AddPerformanceHints middleware (5k reqs) |
19.688 ms |
16.140 ms |
1.22x (-18.0%) |
Config-keyed static Link header memoization |
Runtime & Escaper Hot-Path Improvements (v0.8.0 → v0.9.0)
Measured head-to-head on the same machine (PHP 8.4, opcache.enable_cli=1, getrusage() CPU ms, median of 9 runs after warmup, 2026-12-02) with 100% byte-for-byte HTML parity:
| Workload (5,000 renders) | v0.8.0 CPU |
v0.9.0 CPU |
Speedup | Key Optimization |
|---|---|---|---|---|
Paired leaf @props + static slot (295,000 B) |
7.339 ms |
3.921 ms |
1.87x (-46.6%) |
EncodedHtmlEscaper, BladeSlot lazy attributes, direct $slot->toHtml() |
Self-closing leaf @props (195,000 B) |
8.643 ms |
4.247 ms |
2.04x (-50.9%) |
EncodedHtmlEscaper bypasses Laravel 13 new EncodedHtmlString + Closure alloc |
Paired card @props + merge() + {{ $slot }} (668,890 B) |
25.426 ms |
12.580 ms |
2.02x (-50.5%) |
Zero-Bag BladeAttributeBag::renderWithClass(), BladeSlot, EncodedHtmlEscaper |
Memoized dynamic 1-prop (10 keys, 217,999 B) |
5.244 ms |
1.424 ms |
3.68x (-72.8%) |
BladeMemoEmitter inline type-safe scalar fast-path (0 array alloc on hit) |
Zero-BladeSlot String Slots, Multi-Key Bagless merge([...]), & Report Pipeline (v0.9.0 → v0.10.0)
Measured head-to-head on the same machine (PHP 8.4, opcache.enable_cli=1, getrusage() CPU ms, median of 7–9 runs after warmup, 2026-12-02) with 100% byte-for-byte SHA-256 parity:
| Workload | v0.9.0 CPU |
v0.10.0 CPU |
Speedup | Key Optimization |
|---|---|---|---|---|
Paired leaf @props + static slot (5k, 175,000 B) |
1.510 ms |
1.101 ms |
1.37x (-27.1%) |
Zero-BladeSlot raw string-slot fast-path (0.22 µs/call, zero slot/array alloc) |
Paired card @props + single-key class merge (5k, 442,780 B) |
5.078 ms |
4.866 ms |
1.04x (-4.2%) |
Zero-BladeSlot raw string-slot on dynamic-slot cards |
Paired button @props + multi-key merge(3 keys) (5k, 503,890 B) |
10.010 ms |
7.645 ms |
1.31x (-23.6%) |
BladeAttributeRenderer::renderMerged() + compile-time clean-default fast-path |
PageReport extraction & grouping (30 pages × 50) |
749.411 ms |
62.0–76.3 ms |
9.8x–12.1x (-90%) |
FindingCollector + single-pass Schwartzian sorting + cached diagnoses |
Parent Blade Fast Echoes & Safe @perfCache Fragment Caching (v0.10.1 → v0.11.0)
Measured head-to-head on PHP 8.4 (opcache.enable_cli=1, 2026-12-03) with 100% byte-for-byte SHA-256 parity:
| Workload | Baseline | v0.11.0 |
Speedup | Key Optimization |
|---|---|---|---|---|
Flat zero-component .blade.php (2,000 rows × 4 echoes) |
3.111 ms (stock e()) |
1.270 ms |
2.45x (-59.2%) |
ParentEchoOptimizer routes parent {{ ... }} via EncodedHtmlEscaper |
Paired card @props + single-key class merge (5,000 renders) |
4.866 ms (v0.10.0) |
3.640 ms |
1.34x (-25.2%) |
Parent slot {{ $i }} echo also skips Laravel 13 EncodedHtmlString alloc |
Safe @perfCache L1 fragment hit (2,000 hits) |
5.067 ms (uncached) |
3.154 ms |
1.61x+ | Bounded L1 memo + Laravel Cache with CSRF/Livewire/CSP-nonce guards |
2. Static Code Audit (perf:audit) & Blade Advisor (perf:blade-plan)
Measured across a 3,178-file / 628-component Laravel + Livewire codebase (2026-12-01) with 100% PHP/Rust parity (0 diffs):
| Version & Engine | Workload | Rules / Findings | Isolated Sweep (same run) |
Quiet Apple Silicon | Binary Size | Change |
|---|---|---|---|---|---|---|
v0.3.0 Pure PHP perf:audit |
3,178 files | 16 rules · 1,612 | 544.51 ms |
— | — | Initial pure-PHP static auditor |
v0.4.0 Pure PHP perf:audit |
3,178 files | 16 rules · 1,612 | 247.39 ms (2.2x) |
— | — | O(1) plain-class skip + str_contains() pre-guards |
v0.6.0 Pure PHP perf:audit |
3,178 files | 22 rules · 1,785 | 259.31 ms (2.1x) |
262.46 ms |
— | +6 Livewire/Alpine/Blade rules (+37.5% rules, half the time of v0.3.0) |
v0.3.0 Rust perf-audit v0.1.0 |
3,178 files | 16 rules · 1,612 | 132.53 ms (4.1x) |
— | 419.2 KB |
Static chunking across cores |
v0.4.0 Rust perf-audit v0.1.0 |
3,178 files | 16 rules · 1,612 | 115.69 ms (4.7x) |
42.11 ms |
402.5 KB |
panic = "abort" + zero-allocation ASCII matching |
v0.6.0 Rust perf-audit v0.2.0 |
3,178 files | 22 rules · 1,785 | 75.03 ms (7.3x) |
27.54 ms (9.5x vs PHP) |
468.7 KB |
Lock-free AtomicUsize work-stealing + locked BufWriter + --files-from (-34.6% vs v0.4.0 Rust) |
v0.5.0 Pure PHP perf:blade-plan |
628 comps | 4 strategies | 319.98 ms |
185.36 ms |
— | Pure-PHP component analyzer & safe prop inference |
v0.6.0 Rust perf-audit --plan |
628 comps | 4 strategies | 19.37 ms (16.5x) |
12.28 ms (15.1x vs PHP) |
included | Multi-core Rust planner with 0 diffs across all 628 components |
3. Compiled Size, Memory, Cold-Worker Boot & HTML Footprint
| Dimension | Previous (v0.2.0–v0.5.0) |
Now (v0.6.0) |
Delta | How v0.6.0 Achieves It |
|---|---|---|---|---|
Compiled call-site size (50 <x-card> tags) |
127,450 B (v0.5.0) · 87,150 B (Blade) |
75,000 B |
-41.2% vs v0.5.0 (-13.9% vs Blade) |
Non-recursive call-site stack elision ($activeFns tracking) |
Attribute bag CPU (50,000 merge+class+whereStartsWith) |
880.38 ms (Laravel ComponentAttributeBag) |
340.81 ms |
2.58x (-61.3%) |
Collection-free BladeAttributeBag (zero Collection allocations) |
Cold worker component loading (628 real components) |
628 perf-blade/*.php files & stat calls |
1 OPcache bundle (5.09 MB, php -l clean) |
-99.8% files |
perf:blade:warm precompiles into bootstrap/cache/perf-blade-bundle.php |
Compile-time HTML whitespace (50-card grid) |
22,200 B |
16,050 B |
-27.7% (0 ms runtime) |
BladeWhitespaceCompactor (minifyWhitespace(true)) |
Inline SVG icon payload (48 repeated icons) |
15,840 B |
11,030 B |
-30.4% (-4,810 B) |
SvgSpriteDeduplicator / DeduplicateSvgIcons middleware (60 B hidden sprite) |
Engine & Sweep Hot-Path Speedups (v0.6.0 → v0.7.0)
Measured on the same machine (PHP 8.4, Apple Silicon, median of 5–7 runs after warmup, 100% output & finding parity):
| Hot Path | v0.6.0 |
v0.7.0 |
Speedup | Optimization |
|---|---|---|---|---|
QueryDigest::of()->toArray() (150 queries × 30) |
79.94 ms |
1.92 ms |
41.6x (-97.6%) |
Normalize once per unique SQL string + single repeated() pass |
Compile-time BladeFolder (150 folded calls) |
43.10 ms |
1.76 ms |
24.5x (-95.9%) |
Skip BladeWrapper::wrap() once function exists + cache safety & safe-prop checks |
TraceRecorder flame chart (2,000 nested spans + 100 SQL) |
17.50 ms |
2.30 ms |
7.6x (-86.9%) |
O(1) incremental parent child_ms accounting inside stopSpan() |
BladeAttributeBag::merge() (10,000 merges) |
27.38 ms |
6.12 ms |
4.5x (-77.6%) |
Empty-bag fast path + single-pass merge without intermediate arrays |
SvgSpriteDeduplicator (200 repeated SVGs, 92 KB HTML) |
3.31 ms |
0.79 ms |
4.2x (-76.1%) |
Single-pass O(N) chunk assembly (replaces O(N·M) substr loop) |
HtmlAuditor::audit() (92 KB HTML × 10) |
25.40 ms |
6.37 ms |
4.0x (-74.9%) |
Fast stripos() <head> extraction and tag/attribute pre-guards |
PHP CodeAuditor::scan() (400-file app, 210 findings) |
37.43 ms |
10.65 ms |
3.5x (-71.5%) |
File-level token pre-guards + lazy explode("\n") + single-scan class skip |
Rust perf-audit scan (400-file app, incl. process spawn) |
18.11 ms |
5.49 ms |
3.3x (-69.7%) |
d_type walking, chunked work-stealing, zero-alloc slice checks, file pre-guards |
PHP BladePlanAnalyzer / Rust --plan (50 components) |
4.04 / 6.90 ms |
1.55 / 2.71 ms |
2.6x / 2.5x | Cow<'_, str> zero-allocation comment/PHP stripping + single-pass classify_file() |
perf:pages multi-run sweeps |
audits all N+1 runs | median-only audit | ~80% less RAM | Zero-backtrace warmup, cached gzip bytes, release duplicate non-median HTML |
4. Version-by-Version Capability Matrix
| Capability | v0.2.0 |
v0.3.0 |
v0.4.0 |
v0.5.0 |
v0.6.0 |
v0.7.0 |
v0.8.0 |
v0.9.0 |
v0.10.0 |
v0.11.0 |
|---|---|---|---|---|---|---|---|---|---|---|
perf:pages & perf:requests deterministic profiler |
Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
SEO & Core Web Vitals HtmlAuditor + Speculation Rules / Early Hints |
— | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Blade compiler (compile, memo, static fold, @perf/@blaze/@unblaze) |
— | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| Zero-buffer static wrapper, leaf fast-path & whitespace compaction | — | — | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Dynamic pass-through folding (autoSafeFold), FoldManifest, BladeAttributeBag |
— | — | — | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Unified Blade + SQL + Memory Flame-Chart Profiler (/_perf/profiler, perf:trace:*) |
— | — | — | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Single-file OPcache bundle (perf:blade:warm) & non-recursive stack elision |
— | — | — | — | Yes | Yes | Yes | Yes | Yes | Yes |
Static memo → fold promotion & Octane locale-isolated persistent memo |
— | — | — | — | Yes | Yes | Yes | Yes | Yes | Yes |
Reusable inline SVG sprite deduplication (DeduplicateSvgIcons) |
— | — | — | — | Yes | Yes | Yes | Yes | Yes | Yes |
Static perf:audit rules (100% PHP & Rust parity) |
0 |
16 |
16 |
16 |
22 |
22 |
22 |
22 |
22 |
29 |
Rust acceleration (perf-audit binary + --plan + --changed + release binaries) |
— | v0.1.0 |
v0.1.0 |
v0.1.0 |
v0.2.0 |
v0.2.0 |
v0.2.0 |
v0.2.0 |
v0.2.0 |
v0.3.0 |
Livewire --snapshot-breakdown & CI --save-baseline / --compare gate |
— | — | — | — | Yes | Yes | Yes | Yes | Yes | Yes |
Strict perf:blade-parity CLI, session guard isolation & ExternalBladeBridge |
— | — | — | — | — | Yes | Yes | Yes | Yes | Yes |
Direct CV @props (no extract()), preamble hoisting & single-echo slot elision |
— | — | — | — | — | — | Yes | Yes | Yes | Yes |
Compile-time static memo keys (10x), PCRE2 trie HTML compactor & cached Link hints |
— | — | — | — | — | — | Yes | Yes | Yes | Yes |
EncodedHtmlEscaper, lazy BladeSlot, zero-Bag renderWithClass(), inline 1-prop dynamic memo |
— | — | — | — | — | — | — | Yes | Yes | Yes |
Per-render ParityRequestResetter isolation in perf:blade-parity + parity_reset hook |
— | — | — | — | — | — | — | Yes | Yes | Yes |
Zero-BladeSlot string slots, multi-key bagless merge([...]), View::share() fallback parity |
— | — | — | — | — | — | — | — | Yes | Yes |
Deep SQL bottleneck profiling (--queries, --slow-query-ms, SQL flags, TraceRecorder SQL table) |
— | — | — | — | — | — | — | — | Yes | Yes |
Extensible perf:benchmark architecture (--save/--compare/Markdown) & FindingCollector/HtmlCheck |
— | — | — | — | — | — | — | — | Yes | Yes |
Eloquent hydration/lazy-load profiler, Cache profiler, read-only SQL --explain, perf:doctor |
— | — | — | — | — | — | — | — | — | Yes |
Extended CWV (LCP/INP/CLS), JS/CSS bundle budgets, Auto Early Hints, AddWeakEtag, @perfVitals RUM |
— | — | — | — | — | — | — | — | — | Yes |
Parent .blade.php fast echoes (2.45x) & CSRF/Livewire/nonce-safe @perfCache fragment cache |
— | — | — | — | — | — | — | — | — | Yes |
Built-in Blade component optimizer
Anonymous Blade components (<x-button>, <x-badge>, <x-card>) normally render through Laravel's view factory, file lookup, and event dispatch on every call. In a table or feed with hundreds of rows, that overhead dominates PHP render time.
Register component directories in AppServiceProvider::boot() (or in config/page-performance.php under blade.paths):
use Olgun\PagePerformance\PagePerformance;
PagePerformance::optimize()
->autoSafeFold(true) // auto-detect echo-only @props safe for dynamic compile-time folding
->promoteStaticMemoToFold(true) // optional: auto-fold 100%-static calls of pure memo components (0 ms)
->persistentMemo(true) // optional: locale-isolated cross-request worker memo for Octane/FrankenPHP
->minifyWhitespace(true) // compile-time structural HTML compaction (zero runtime CPU)
->in(resource_path('views/components'))
->in(resource_path('views/components/icons'), memo: true)
->in(resource_path('views/components/static'), fold: true)
->includeVendorAnonymous();
Single-file OPcache component bundle (perf:blade:warm)
Precompile every configured anonymous Blade component into one OPcache-preloadable PHP file (bootstrap/cache/perf-blade-bundle.php) so cold workers skip per-component compileFunction(), realpath(), filemtime(), and require_once calls:
php artisan perf:blade:warm # build bootstrap/cache/perf-blade-bundle.php
php artisan perf:blade:warm --include-vendor
php artisan perf:blade:warm --clear # remove the precompiled bundle
In production (app.debug === false), BladeRuntime loads the bundle once at boot automatically. Components with conflicting use aliases are skipped safely and fall back to their isolated perf-blade/<hash>.php file. Non-recursive component call sites automatically elide stack save/restore variables for smaller compiled views.
Automatic inline SVG sprite deduplication (DeduplicateSvgIcons)
Attach Olgun\PagePerformance\Http\Middleware\DeduplicateSvgIcons on HTML routes (or call SvgSpriteDeduplicator::deduplicate($html) directly) to hoist repeated identical <svg> icons into one hidden <defs><symbol> sprite before </body> and rewrite duplicates to <use href="#pp-svg-..." />. Skips <svg data-no-sprite>, gradients, clip paths, masks, filters, inner IDs, and Alpine/Livewire SVG bindings automatically.
Dynamic pass-through folding & auto-safe prop inference
Compile-time folding works even when components receive dynamic pass-through attributes (:id="$id", :disabled="$flag", :wire:loading="$loading", data-note="Hi {{ $name }}") and dynamic slots ({{ $body }}, <x-slot:header>{{ $title }}</x-slot:header>):
- Pass-through attributes and slots fold via reversible compile-time placeholders with exact HTML/Livewire/Alpine boolean semantics (
wire:*andx-dataemit""whentrue, standard boolean attributes emit their key name,false/nullomit the attribute) and HTML escaping. - Declare
@perf(fold: true, safe: ['title'])or@perf(fold: true, unsafe: ['attributes', 'slot'])for explicit control, or enable->autoSafeFold(true)to letFoldSafePropAnalyzerinfer echo-only@propsautomatically without manualsafe: [...]lists. @unblaze(scope: ['title' => $title])works with dynamic folded props in scope,@verbatimblocks survive folding intact, conditional slots (@if (...) <x-slot:...> @endif) automatically fall back to compiled functions, and static-starting folded HTML emits zero runtimeob_start()/ltrim()overhead.- Automatic fold dependency invalidation (debug/local only):
FoldManifestrecords folded child paths and mtimes in the first 4 KB header of compiled parent views so editing a folded child automatically recompiles parent views in local/debug mode — with zero wildcardView::composer('*')overhead in production.
Auto-optimization advisor (perf:blade-plan)
Scan your anonymous Blade components and generate an optimal PagePerformance::optimize() configuration automatically:
php artisan perf:blade-plan # classify fold / memo / compile / exclude (auto-uses Rust when built)
php artisan perf:blade-plan --detail # inspect auto-detected safe props and reasons per component
php artisan perf:blade-plan --include-vendor
php artisan perf:blade-plan --engine=php # force pure PHP (default: auto)
php artisan perf:blade-plan --json
Strict HTML parity checker (perf:blade-parity)
Before turning the compile tier on across an application, verify that rendered pages match standard Blade byte-for-byte:
php artisan perf:blade-parity / /dashboard /settings
php artisan perf:blade-parity /dashboard --as=me@example.com --host=acme.app.test
php artisan perf:blade-parity /dashboard --ignore-whitespace
php artisan perf:blade-parity /dashboard --ignore-whitespace --ignore-comments
php artisan perf:blade-parity /dashboard --json
The command clears compiled views between passes, renders each URL with the optimizer OFF and ON, normalizes volatile per-request tokens (_token, csrf-token, wire:snapshot, wire:id, nonce), and prints the exact byte offset, line number, and excerpt of the first mismatch (exit 0 when all URLs match, 1 when any URL differs). Strict byte-for-byte comparison is the default; --ignore-whitespace collapses inter-tag whitespace. It refuses to run in production.
Applications with minifyWhitespace(true): the minifier removes plain HTML comments (<!-- section -->) and inter-tag whitespace on purpose, so stock Blade and the optimizer differ on every page. Add --ignore-comments with --ignore-whitespace: it removes plain comments from both renders with the minifier's own rule and keeps the Livewire morph markers (<!--[if BLOCK]><![endif]-->, <!--[endif]-->), so a lost marker still shows as DIFF. When a run fails with minifyWhitespace(true) on and one of the two options off, the command prints this hint.
Markup that changes on every request (for example id="widget-{{ Str::random(6) }}"): add regex => replacement pairs under parity_ignore_patterns in config/page-performance.php. The command applies them to both renders after the built-in normalizers:
'parity_ignore_patterns' => [
'/\bid="widget-[A-Za-z0-9]+"/' => 'id="widget-__RANDOM__"',
],
An entry that does not compile, or that is not a string pair, is skipped with a warning (in --json: invalid_ignore_patterns); the command never stops because of it. The JSON output also has ignore_comments, minify_whitespace and ignore_patterns (the count of applied patterns).
Request-state isolation between renders: After every standard-Blade and optimized-Blade render (and between URLs in a multi-URL run), perf:blade-parity resets per-request state via ParityRequestResetter:
- Runs the full HTTP termination lifecycle (
Kernel::terminate($request, $response)— dispatchingTerminating, calling terminable middleware, and invoking$app->terminate()), then trims request-added terminating callbacks back to the pre-render baseline. - Calls
app()->forgetScopedInstances()(plus matching Facade caches) so allapp()->scoped(...)services start fresh. - Flushes
ViewFactory::flushState()(sections, stacks,@once/@pushOnce, component stacks, fragments,renderCount) and restoresView::share()keys to their pre-render baseline. - Resets resolved auth guards (
SessionGuardHelper::reset()), session drivers (SessionManager::forgetDrivers()andsession.store), queued cookies (CookieJar::flushQueuedCookies()),Vite::flush()($preloadedAssets),Context::flush(), Livewire (app('livewire')->flushState()when installed), and restores the baseline consolerequestinstance. - Evicts any non-infrastructure container singleton resolved for the first time during a render (plus its Facade cache), so lazy
app()->singleton(...)collectors (such as JSON-LD /<head>/ SEO / breadcrumb collectors) start empty on every pass and every URL.
What an application must reset itself (if applicable): Singletons that were already resolved during ServiceProvider::boot() (or mutable static properties on application classes) are preserved by default so boot-time registries are never wiped. If your application stores per-request state in a boot-resolved singleton or static property, bind it with app()->scoped(...), clear it in an app()->terminating(...) callback / Terminating listener, or register it in config/page-performance.php under 'parity_reset' (accepts container abstracts to evict or callable(Application): void callbacks).
Livewire snapshot property breakdown & CI regression gate (perf:pages)
Inspect which public Livewire properties bloat each snapshot (recording property names and byte lengths only — never values), or gate CI builds against deterministic counters (queries, duplicates, n_plus_one, html_defects, blade_unoptimized, wire_bytes, snapshot_bytes — never flaky milliseconds):
php artisan perf:pages --snapshot-breakdown
php artisan perf:pages --save-baseline=perf-baseline.json
php artisan perf:pages --compare=perf-baseline.json --byte-tolerance=5
Unified Blade + SQL + Memory Flame-Chart Profiler (perf:trace:*)
Enable local/debug tracing via PagePerformance::debug() or PAGE_PERFORMANCE_DEBUG=true (refuses production by default; zero runtime overhead when disabled) to record hierarchical component spans correlated with SQL query counts, duplicate SQL queries, peak memory, and raw/gzip HTML bytes:
php artisan perf:trace:list # list recent traces (Render, Total, SQL, Peak RAM, Wire KB)
php artisan perf:trace:show --tree # inspect the latest trace with an ASCII flame tree & hints
php artisan perf:trace:show <id> --json # export a specific trace payload
php artisan perf:trace:clear # clear stored traces
Visit /_perf/profiler in local development for the self-contained interactive Flame-Chart Profiler UI (zero external CDN dependencies, CSP-nonce aware, path-traversal-safe ULID trace IDs) and compact floating debug card.
Or annotate individual anonymous Blade templates with @perf(...) (or @blaze(...) for full directive compatibility):
@perf(memo: true)
@props(['label', 'variant' => 'default'])
<span {{ $attributes->class(['badge', "badge-{$variant}"]) }}>{{ $label }}</span>
Use @unblaze(scope: [...]) to keep a dynamic island inside a compile-time folded component:
@perf(fold: true)
@props(['title'])
<article class="card">
<h2>{{ $title }}</h2>
@unblaze(scope: ['title' => $title])
<span>Viewed at {{ now()->toTimeString() }} for {{ $scope['title'] }}</span>
@endunblaze
</article>
Three optimization tiers — when to use each
See Performance: Previous Versions vs Now above for full cross-version charts and isolated PHP 8.4 measurements.
| Strategy | Speedup vs Blade (5,000 renders) |
When to use |
|---|---|---|
| Standard Laravel Blade | 1.0x (baseline) |
Class-based components, $component readers, dynamic <x-dynamic-component> |
Compiled PHP function (compile: true, default) |
16.8x–34x+ (v0.8.0: 2.05x faster than v0.7.0) |
Any anonymous component with @props (direct CV, no extract()), @aware, @class/@style, :attributes, or slots |
Bounded request memo (memo: true) |
44.9x–400x+ (v0.8.0: 10.04x faster static hits) |
Repeated icons, badges, and status pills (self-closing or static slots; capped at blade.memo_limit, default 2048) |
Dynamic pass-through folding (autoSafeFold(true)) |
29.4x (-96.6% CPU) |
UI wrappers receiving dynamic attributes/slots and echo-only @props |
Compile-time static folding (fold: true / promoteStaticMemoToFold(true)) |
552x (-99.8% CPU) |
Pure static wrappers and literal-prop UI primitives (with @unblaze for dynamic islands) |
Eight edge cases prevented by design
- Byte-for-byte compile-tier HTML parity: incremental nested-component and nested-
<x-slot>extraction (BladeSlotExtractor), conditional-slot fallback to standard Blade,@props??null fallback, non-@propscamelCase attribute variables (AnonymousComponent::data()parity), compile-time$__boundKeysescaping on bound attributes (@class,:class,@style,:attr) without double-escaping forwarded:attributesor@props(a call without an aware stack, forward, spread or repeated key to a@propscomponent that reads$attributessanitizes its bound non-prop values at the call site and skips the runtime loop: 4.9–6.6% faster onblade.bound-attrs-leafandblade.card-class-merge, measured 2026-12-03), and exactComponentAttributeBagkey ordering/spacing. - Safe direct CV
@propscompilation (DirectPropsCompiler): verifies every component withPhpToken::tokenize()and automatically falls back toextract()whenever undeclared named slots ($header), self-referential RHS assignments, array=>reads, conditional/braceless assignments, post-foreachreads,@props/@awareoverlaps,$app/$errorsshadowing, or@includeappear. - No
$appprop shadowing:@props(['app'])extracts user props before setting fallback$app,$errors, and$__livewiredefaults. - Comment-safe
@awareand@props: Blade comments,@verbatim,@php, and<?phpblocks are stripped before directive parsing, so mentioning@awarein a comment never breaks compilation. - Automatic fold safety guard:
FoldSafetyCheckerrefuses to fold components referencingauth(),session(),request(),@csrf,$errors,old(),now(),today(),rand(),Str::uuid(),route(),url(),__(),DB::,@once/@push, or Livewire tags (falls back to compiled function, or throwsUnsafeFoldExceptionwhenblade.strict_foldistrue). - Isolated compiled cache &
view:clearrecovery: compiled component functions write tostorage/framework/views/perf-blade/without touching Laravel's standard compiled view files (soview('components.foo')and@include()keep working), andBladeRuntime::compileFunction()checksis_file()so long-lived workers recover cleanly afterphp artisan view:clear. - Bounded memoization with static slots & Octane isolation: memoizes both self-closing and static-slot components while capping per-request (
blade.memo_limit = 2048) and locale-isolated persistent (1024) caches and flushing state cleanly on Laravel Octane requests. - Zero global
View::composer('*'): resolves@awarevia a lightweight runtime stack (elided automatically on leaf components with no@awaredescendants or dynamic includes), preserves fullBladeProfiler/TraceRecordertelemetry when observing, and delegates cleanly whenlivewire/blazeis also installed (for example, with Flux UI).
Instant-page helpers
Speculation Rules (@perfSpeculationRules)
Place @perfSpeculationRules in your layout <head> or before </body> to enable conservative same-origin browser prefetching on public multi-page links:
@perfSpeculationRules
It automatically excludes /logout, /logout/*, /admin, /admin/*, /livewire-*, Livewire SPA links ([wire\:navigate]), [data-no-speculate], and [rel~=nofollow], so it never triggers duplicate fetches with wire:navigate or mutating endpoints.
Opt-in AddPerformanceHints middleware
Register Olgun\PagePerformance\Http\Middleware\AddPerformanceHints on public routes to emit HTTP Link: <...>; rel=preload headers (usable by CDN/server 103 Early Hints) configured under page-performance.preload:
// config/page-performance.php
'preload' => [
['href' => '/fonts/inter.woff2', 'as' => 'font', 'type' => 'font/woff2', 'crossorigin' => true],
],
Use AddPerformanceHints::class.':60' to attach Cache-Control: public, max-age=60, s-maxage=60, stale-while-revalidate=120. The formatted Link header is memoized across requests keyed by page-performance.preload. The middleware refuses to mark a response public when:
- the response sets a cookie, contains a CSRF token (
_token/csrf-token), or mounts a Livewire snapshot (wire:snapshot); - the request has an
Authorizationheader (or HTTP basic auth), or its session holds a Laravel login key (login_*); - the app already set its own
private,no-storeorno-cachepolicy on the response.
The middleware reads the directives that the app set itself (Symfony keeps them apart from the computed header), so a bare Cache-Control: no-cache is kept, although its computed header equals Symfony's default (no-cache, private). If a future Symfony release no longer keeps those raw directives, the middleware falls back to the computed header, and a bare no-cache then looks like the default: set no-store or private to opt a route out on every Symfony release.
With page-performance.auto_early_hints on, the middleware reads the high-priority LCP image, stylesheets and font preloads from the first response of each route, and memoizes the Link header by host and path (at most 256 routes). Two hosts (tenants, host-based locales) never share one header.
Static code auditor (perf:audit)
Scan Blade views and PHP classes for 22 deterministic Blade, Livewire, Alpine, and Core Web Vitals anti-patterns (including unkeyed Livewire loops, ::all()/->get() Livewire property bloat, queries in render(), unthrottled Alpine @scroll/@resize, inline <svg> in loops, and conditional <x-slot> fold blockers) before opening a browser:
php artisan perf:audit # scan app/ and resources/views/
php artisan perf:audit --changed # audit only git-modified/untracked PHP & Blade files
php artisan perf:audit resources/views # scan a specific path
php artisan perf:audit --category=livewire # filter: blade | livewire | alpine | cwv
php artisan perf:audit --json # machine-readable output
php artisan perf:audit --engine=php # force pure PHP scanner (default: auto)
perf:audit and perf:blade-plan run in pure PHP with zero extra packages. For very large repositories, compile the bundled zero-dependency multi-core Rust binary (or download prebuilt macOS/Linux binaries attached to GitHub Releases):
bash vendor/olgunozoktas/laravel-page-performance/bin/build-rust.sh
When the binary is present (or configured via PAGE_PERFORMANCE_RUST_BIN), both perf:audit and perf:blade-plan use it automatically (AtomicUsize work-stealing + buffered stdout) and fall back transparently to pure PHP if absent. Measured on a 3,178-file / 628-component Laravel + Livewire application (2026-12-01): pure PHP audited all 3,178 files across 22 rules in 262.46 ms vs Rust in 27.54 ms (9.5x faster, 100% parity across all 1,785 findings), and planned all 628 components in 185.36 ms (PHP) vs 12.28 ms (Rust, 15.1x faster, 0 diffs).
From perf-audit v0.3.0, the binary also runs the 7 plain-PHP rules (php-query-in-loop, php-cache-in-loop, php-http-in-loop, php-unbounded-get, php-collection-count, php-env-outside-config, php-job-missing-without-relations) with its own PHP tokenizer, so all 29 rules run in one native pass. Before, the bridge ran these 7 rules again in PHP after each Rust scan. Measured on a 2,773-file Laravel + Livewire application (2026-12-04, warm file cache, median of 7): perf:audit through the bridge took 30.6 ms instead of 509.3 ms (-94%), with the same 1,240 findings. The output matches the PHP rules in every field (file, line, rule, category, severity, message, snippet): 0 diffs across 3,400 PHP files of three code bases. An older binary still works: the JSON of v0.3.0 says "php_rules":true, and without it the PHP pass runs as before. Rebuild with bin/build-rust.sh to get the speed.
What it measures
| Column | Meaning |
|---|---|
ms |
Median of the timed runs. Never the mean — one GC pause ruins a mean and nobody reading it can see that it did. |
spread |
How far the runs disagreed. Above ~25% the position is not trustworthy, and the report says so. |
cold |
The discarded first run. Kept and shown, never averaged in. |
db |
Database time. |
lw |
Livewire time, children counted once. Empty when Livewire is absent or app.debug is false. |
q / dup |
Queries, and how many executions a fix would delete. |
snap |
Livewire snapshot bytes — sent up and back on every interaction. |
html |
Response bytes, uncompressed. |
wire |
What the visitor downloads. Estimated gzip size — the number payload-heavy judges. |
The diagnosis vocabulary
Every label has a stated rule, so it can be argued with.
| Label | Rule |
|---|---|
repeated-query |
identical SQL and bindings ran ≥2× |
n-plus-one |
identical normalised SQL, ≥5 distinct binding sets |
db-bound |
database time ≥ 50% of the request and ≥ 10 ms |
livewire-bound |
Livewire ≥ 40% of the request and ≥ 10 ms |
child-heavy |
one child ≥ 25% of its parent's render |
livewire-lazy-candidate |
a characteristic, never a defect: a nested child that took ≥ 25% of its parent's render and ≥ livewire_lazy.min_ms (default 20 ms). It names the child, its time and share, and the lazy hint. Lazy loading helps only when the first paint does not need the child; list such children in page-performance.livewire_lazy.ignore |
payload-heavy |
response ≥ 100 KB compressed |
snapshot-heavy |
snapshot ≥ 4 KB, or ≥ 3% of the page |
vendor-bound |
outbound HTTP was made inside the render |
uncacheable |
no-store on a page that mounts a component — and it says whether a per-session token makes the page uncacheable anyway |
query-heavy |
over the page's query budget |
unbudgeted |
no budget and no stated reason for not having one |
missing-html-lang · missing-title · missing-meta-description · missing-h1 · multiple-h1 · image-missing-alt |
SEO defects detected on full HTML documents (<html) |
render-blocking-script · font-preload-no-crossorigin · image-missing-dimensions · lcp-lazy-conflict · excess-high-priority · duplicate-alpine |
Core Web Vitals (LCP, CLS, INP) and asset defects detected on full HTML documents |
missing-canonical · large-dom · alpine-data-heavy · inline-svg-bloat · inline-script-heavy |
HTML characteristics (reported in Characteristics, never in Defects) |
ok |
none of the above — printed with its numbers, because a healthy row and an unmeasured row must not look the same |
Defects and characteristics are separate, and only one of them should reach zero
Under the summary come two tables, and the difference between them is the point.
Defects are things that are wrong and that you can fix: a repeated query, an N+1, an outbound call inside a render, a page over its budget.
Characteristics are where a request spends itself — db-bound,
livewire-bound, a page that cannot be shared-cached because it carries a
per-session token, a row whose spread says the measurement is not trustworthy.
They are worth printing and they are not defects.
Mixing them makes the number unusable. On one real board, every duplicate query was fixed and the report still showed five "findings", none of which anybody should act on — and a count that cannot reach zero is a count people stop reading.
One row per defect, not a paragraph per page:
Findings .............................................. 52, worst page first
+----+----------------------+-------------------+------------------------------------------+---------------------------------+
| # | page | finding | evidence | where |
+----+----------------------+-------------------+------------------------------------------+---------------------------------+
| 1 | board.home | repeated-query | x2 select count(*) from "listings" … | app/Boards/ReadsBoard.php:49 |
| 3 | board.home | livewire-bound | 23.7 ms of 40.5 ms in Livewire | — |
| 4 | board.home | payload-heavy | 268K of HTML | — |
| 7 | board.similar-boards | noisy-measurement | 41% spread — position not trustworthy | — |
+----+----------------------+-------------------+------------------------------------------+---------------------------------+
The where column is an OSC 8 hyperlink. Click it and the file opens at the
line.
// config/page-performance.php
'editor' => env('PAGE_PERFORMANCE_EDITOR', 'phpstorm'),
phpstorm · idea · vscode · cursor · sublime · textmate · zed ·
file. An empty value prints plain text, and so does an editor the package does
not recognise — emitting a URL scheme nothing will answer is worse than emitting
none.
It degrades whenever the output is not a terminal. Piped into a file or a pager, those escapes would sit in the output as control characters and stop a grep matching the very paths the column exists to hand over. Both directions are tested.
Three things it gets right that a naive sweep does not
1. The cold-process trap. The first request handled in a PHP process costs a fixed amount regardless of which page it is. Measured on a real application:
| Order | Page | Wall |
|---|---|---|
| 1st in process | / |
150.4 ms |
| 1st in process | /products |
92.0 ms |
| 3rd–6th | / |
41–53 ms |
A sweep without a warmup charges that to whichever page ran first and presents the result as a ranking by cost. This warms first, discards the cold run, and shows it in its own column.
2. Milliseconds are a column, never the sort key. Rows order by avoidable queries, then database time, then bytes, and only then the clock. Deterministic evidence decides the order; time is the tiebreak of last resort.
3. One defect is one row. A finding carried by 27 pages is printed once,
with 27 pages in the page column — not 27 times. A real sweep produced 77
findings of which 28 were the same table-existence check from the same line;
grouped, the same sweep reports 8. A report you have to de-duplicate by eye
is a report that gets skimmed.
4. Ratio labels have an absolute floor. A 1.8 ms page is not db-bound
because 0.9 ms of it was a settings lookup. Below 10 ms a share is arithmetic,
not a finding — and noisy-measurement needs both a wide spread and a 15 ms
absolute gap, because 340% of 2.5 ms is jitter.
5. Page weight is judged COMPRESSED, because that is what a visitor pays. Measured on a real board home page: 287,831 bytes of HTML arrive as 32,514 over the wire, 89% smaller. The things that make server-rendered HTML large — repeated Tailwind classes, repeated inline SVG, framework comments — are exactly what a compressor removes. Judging the uncompressed number sends people to refactor a shared icon component for about two hundred real bytes. Both figures are reported so the ratio is visible.
6. in (?, ?, ?) collapses to in (?) before anything is counted. A chunked
or paginated loop emits the same statement with a different number of
placeholders each pass. Unnormalised those are separate shapes and the loop is
reported as nothing at all.
The gate half
Timings are reported. Only deterministic counters may be asserted:
| Bucket | Gate? |
|---|---|
| query count, avoidable executions, response bytes, component count | yes |
| wall time, database time, memory | never |
A timing assertion in a parallel suite measures the other workers. One real suite reported 232, then 478, then 11 failures across three runs of identical code. A gate that fails for reasons nobody can act on is one people learn to ignore.
Budgets live in your published config, measured against your fixture:
'budgets' => [
'board.home' => [
'queries' => 20, 'duplicates' => 2, 'bytes' => 199_000, 'components' => 3,
'measured' => '2026-08-26',
'why' => '17 queries and 155 KB over the seeded board. A ceiling with headroom,
not an exact match. Duplicates is 2 and that is the remaining debt.',
],
],
why and measured are not decoration. A number you can raise without writing
a sentence beside it is a number that gets raised without being read — which is
how a budget stops being one. The ratchet: a budget may fall in any commit;
raising one means rewriting the reason.
There is no --update-baseline. A budget a machine can rewrite is not a
budget. Re-measure with perf:pages --json and copy the number in by hand.
Assert them in your own test — Budgets::all(), Budgets::covers() and
Budgets::durationKeys() are the reader.
Two costs most tools miss
Outbound HTTP inside a render. A query is as slow as your database; a third
party's API is as slow as somebody else's afternoon. vendor-bound names the
host and the count. It sees Laravel's own HTTP client — a raw curl handle or a
vendor SDK with its own Guzzle goes unseen, so the label firing is proof and its
silence is not.
Pages that no cache may hold. Livewire's SupportDisablingBackButtonCache
sets Cache-Control: no-store on every page that mounts a component. That is
right behind a login and quietly expensive on a public one: a landing page you
wanted a CDN to hold is uncacheable because it carries a single component.
The finding names the real blocker, not just the cause — and that distinction is a security one. Saying only "Livewire set no-store" invites removing the header and putting the page behind a CDN. Measured on a real board home page, that would have served one visitor's CSRF token, session cookie and Livewire snapshot checksum to the next visitor. So the row says whether the page carries per-session state, and only a page carrying none is worth questioning.
Honest limits
- The per-component phase breakdown is local-only, permanently. Livewire
gates its own
profileevent onconfig('app.debug')at every trigger site. Production runsAPP_DEBUG=falseand must. Snapshot bytes are the Livewire metric that survives production — they are read from the response HTML and need no instrumentation at all. - It measures your local database, which is the point: on an empty database a listing page renders no rows, and that is a number about software you do not ship. It refuses to run against production.
- It never writes. GET routes only; mutating verbs are excluded structurally, not by a list somebody maintains.
- Times depend on opcache in the CLI. PHP's CLI default is
opcache.enable_cli=0, and then every render compiles the views again. Measured on a Livewire app (2026-11-07): one component took 15.9 ms with it off and 6.7 ms with it on, and only the run with it off reportedchild-heavy. When it is off, the report prints aWARNline before the table (andopcache_warningin--json). Sizes and query counts do not change. For a time finding, runphp -d opcache.enable_cli=1 artisan perf:pages …on a quiet machine. - Times depend on a quiet machine. The command reads the 1-minute load
and the core count before the first page. When the load is over the core
count, it prints a
WARNline before the table (andload_warningin--json). Measured on a Livewire app (2026-11-07): every run of one evening started at a load of 22 to 49 on a 12-core Mac, and the same page spread 47% to 175% between runs. Sizes and query counts do not change. - Parameterised routes are excluded and counted, until you name their
values. A guessed id answers 404 in about 3 ms and would rank as the
fastest page in the application, so the package never guesses. Give a route
its values in
page-performance.parametersor with--param(see Commands); a route without them stays in the skipped list, with the parameters it lacks. A value whose row is gone answers 404, and the page is reported as NOT THE PAGE, never ranked.
Commands
php artisan perf:pages # everything
php artisan perf:pages --only=board # substring filter on the route name
php artisan perf:pages --queries # top normalized SQL shapes by total time, flags (SLOW/DUP/N+1/SELECT */LEADING-%/FUNC-IN-WHERE/OFFSET/ORDER-RAND), and call sites
php artisan perf:pages --queries --slow-query-ms=25 # custom slow-query threshold in ms (default: page-performance.slow_query_ms = 50)
php artisan perf:pages --explain # read-only EXPLAIN of the slowest SELECTs: FULL-TABLE-SCAN, SMALL-TABLE-SCAN, USING-FILESORT, USING-TEMPORARY, index advice
php artisan perf:pages --repeat=9 # more iterations
php artisan perf:pages --shuffle # if the ranking changes, it is noise
php artisan perf:pages --as=me@example.com # measure authenticated pages
php artisan perf:pages --host=acme.app.test # measure subdomain-routed tenant pages
php artisan perf:pages --no-html-audit # skip SEO and Core Web Vitals HTML checks
php artisan perf:pages --param=posts.show:post=hello-world # a value for a route parameter
php artisan perf:pages --json # includes queries, Livewire, Blade optimizer, and HTML audit (plus query_breakdown with --queries)
php artisan perf:requests --queries # per-request SQL bottleneck breakdown for POST/API requests
php artisan perf:blade-parity / /dashboard # byte-for-byte HTML parity check (standard Blade vs optimizer)
php artisan perf:audit # static Blade, Livewire, Alpine, and CWV code audit
php -d opcache.enable_cli=1 artisan perf:benchmark --suite=all # run all 21 built-in benchmarks with SHA-256 parity checks
php -d opcache.enable_cli=1 artisan perf:benchmark --save=/tmp/base.json # save immutable baseline snapshot (Memento)
php -d opcache.enable_cli=1 artisan perf:benchmark --compare=/tmp/base.json --format=markdown --fail-on-regression=15
Repeatable benchmark suite & architecture (docs/ARCHITECTURE.md): php artisan perf:benchmark (or composer bench / bin/benchmark inside this package) runs 15 repeatable benchmarks across 5 suites (blade, html, query, report, audit), verifying byte-for-byte SHA-256 parity against stock Laravel Blade on every Blade case, warning on disabled OPcache or high CPU load (LoadState), saving/diffing Memento JSON snapshots (--save=, --compare=, --fail-on-regression=), and formatting output as table, json, or markdown. Register custom BenchmarkCase classes in config('page-performance.benchmarks'). During a run, the runner sets opcache.file_update_protection to 0 and then puts the old value back: with the PHP default (2 seconds), OPcache does not cache a view compiled in the last 2 seconds, and two runs with different values gave a false difference of up to 9%. The JSON meta records the value as opcache_file_update_protection. See docs/ARCHITECTURE.md for the full architecture diagram and design pattern guide.
Database query bottleneck breakdown (--queries & /_perf/profiler): every perf:pages and perf:requests run already records SQL counts, total DB time, exact duplicate executions (repeated-query), N+1 loops (n-plus-one), and db-bound pages. Pass --queries (with optional --slow-query-ms=50 or PAGE_PERFORMANCE_SLOW_QUERY_MS) to rank the top normalized SQL shapes by cumulative time with clickable call sites (where) and actionable bottleneck flags (SLOW, DUP, N+1, top-level SELECT *, LEADING-%, FUNC-IN-WHERE, deep OFFSET, and ORDER-RAND). Bindings are hashed or boolean-checked at the capture boundary so raw PII values are never stored or printed. Debug traces (TraceRecorder, perf:trace:show, and /_perf/profiler) record the same top normalized sql_queries and surface slow-query recommendations automatically.
Read-only EXPLAIN (--explain): perf:pages --explain and perf:requests --explain run EXPLAIN on the slowest distinct SELECT queries of each page (never a write, a lock or a multi-statement). A sequentially scanned table with fewer estimated rows than page-performance.explain_min_rows (default 100, env PAGE_PERFORMANCE_EXPLAIN_MIN_ROWS, 0 keeps every scan) is a SMALL-TABLE-SCAN, not a FULL-TABLE-SCAN: a planner reads a tiny table in full even when an index exists. The estimate comes from MySQL's EXPLAIN rows, PostgreSQL's Plan Rows of an unfiltered scan or pg_class.reltuples; SQLite gives none, so its scans stay FULL-TABLE-SCAN. The index advice (Consider index on table(columns)) is not given when an existing index already starts with those columns (read once for each table with Laravel's schema getIndexes()).
Session guard for --as=: perf:pages and perf:blade-parity write the session key using the configured session guard (page-performance.guard, default 'web', env PAGE_PERFORMANCE_GUARD) and call Auth::forgetGuards() while restoring the default guard between pages, so token-guard API routes (such as auth:sanctum) measured earlier in the same sweep never break later signed-in web pages. If your application uses a custom session guard (for example 'admin'), set 'guard' => 'admin' in config/page-performance.php.
--param is repeatable, in the form route.name:parameter=value, and wins
over the config for one run. To measure a page with a parameter on every run,
name its values in the published config:
// config/page-performance.php
'parameters' => [
'posts.show' => ['post' => 'hello-world'],
'users.posts.show' => ['user' => '1', 'post' => 'hello-world'],
],
An optional parameter ({page?}) without a value is left out of the address.
Exit codes: 0 measured · 2 nothing could be measured, which is not a
pass · non-zero on bad usage.
A sweep measures every page in one process. The command raises PHP's memory
limit to page-performance.memory_limit (default 1G,
PAGE_PERFORMANCE_MEMORY_LIMIT) before it starts, and never lowers it. A sweep
of 194 pages of a Livewire application ran out of the CLI default of 128M. Set
it to '' to leave the limit as it is.
Requests
perf:pages sends GET only. perf:requests sends the requests that you name
in the published config, with any method, headers and a JSON body, and prints
the same report: a row for each request, the same Defects, the same --json.
// config/page-performance.php
'requests' => [
'posts.store' => [
'method' => 'POST',
'path' => '/api/posts',
'headers' => ['Authorization' => 'Bearer {fixture.token}'],
'json' => ['title' => 'Hello', 'author_id' => '{fixture.user_id}'],
],
],
'fixture' => App\Support\PerformanceFixture::class,
// app/Support/PerformanceFixture.php
use Olgun\PagePerformance\RequestFixture;
final class PerformanceFixture implements RequestFixture
{
public function setUp(): array
{
$user = User::factory()->create();
return ['token' => $user->createToken('perf')->plainTextToken, 'user_id' => $user->id];
}
public function tearDown(): void {}
}
php artisan perf:requests # every named request
php artisan perf:requests --only=posts # substring filter on the request name
php artisan perf:requests --repeat=9 --json
Nothing that it writes stays. The fixture runs in a database transaction, and each run of a request in an inner transaction. Both roll back, so the table has no new row when the command ends. During the runs:
- An outbound HTTP call through Laravel's client is refused before it is sent
(
Http::preventStrayRequests()), and its row fails withoutbound call refused: <host>. A raw curl handle or an SDK with its own Guzzle is not seen. - Mail goes to an
arraymailer, and a queued job to anullqueue. Both settings are put back after the run. - A cache write, a file write and a write on a second database connection are
not rolled back. Use the
arraycache store insetUp()when a request writes to the cache, or lifts a rate limit, and put it back intearDown().
{fixture.key} in a path, a header value or a body string takes the value
that setUp() returned. A body value that is only the placeholder keeps the
type, so an id stays an integer. A placeholder without a value fails its row
and names the key. Accept: application/json is added when no Accept header
is named, and Content-Type: application/json when a request has a body.
Budgets are judged here, unlike in perf:pages: a request runs on the rows
of your fixture, so its budget means the same thing on every run. The key in
page-performance.budgets is the request name. A request over its queries
shows query-heavy. A request with no budget and no reason in
page-performance.unbudgeted shows the unbudgeted Defect.
A write is not redirected: its 302 is its answer. A GET request follows one hop, as a page does. The command refuses to run in production.
The agent skill
The repository ships a skill at .claude/skills/page-performance/SKILL.md. Copy
it into a project so an agent working there knows how to read the output, which
findings are safe to act on, and — the part that matters — the two that are
dangerous to "fix":
mkdir -p .claude/skills
cp -R vendor/olgunozoktas/laravel-page-performance/.claude/skills/page-performance .claude/skills/
It carries the measured lessons rather than the API: that a navigation memo
saved 0.002 ms, that a 280 KB page ships as 30 KB, that removing no-store from
a page with a session token publishes one visitor's CSRF token to the next, and
that Livewire::test() on a #[Lazy] component renders the placeholder — so an
authorization test written the obvious way asserts 403, gets 200, and protects
nothing.
Tests
composer test # pint --test, phpstan level max, pest
vendor/bin/pest tests/Feature/MeasureRequestsTest.php # perf:requests only
Every detector is proved able to fire and able to stay quiet — including
a page with nothing wrong, which must produce exactly ok. A detector that
reports nothing everywhere cannot be told from a broken one.
Shared runtime with laravel-blade-optimizer
The Blade runtime and the HTTP helpers also ship in the standalone
olgunozoktas/laravel-blade-optimizer package. Maintainers keep the two copies
equal with bin/sync-blade-optimizer (in the repository, not in the Composer
package):
bin/sync-blade-optimizer # plan: list each shared file that differs
bin/sync-blade-optimizer --check # exit 1 on drift or a missing file (CI)
bin/sync-blade-optimizer --apply # copy the shared files, with namespace and config key mapped
It maps Olgun\PagePerformance to Olgun\BladeOptimizer and page-performance.
config keys to blade-optimizer., and it never compares the four adapter files
that differ on purpose. --target=DIR names the other checkout (default
../laravel-blade-optimizer).
Where this came from, and what else runs on it
This package is built and proved against real Laravel and web applications maintained by the same author:
| Logo | Product | What it is |
|---|---|---|
| SeeRanks | Transparent product discovery and ranking board for developer products (Laravel + Livewire 4) — where the cold-process trap, CSRF no-store finding, and deduplicated sweeps were measured. |
|
| Main App | Curated multi-platform application directory (macOS, web, iOS, Windows) running Laravel + Livewire — where unified Blade compilation ($app prop safety, comment-safe @props), PHP/Rust perf:audit parity, and HtmlAuditor sweeps are proved in production. |
|
| DataVisitors | Privacy-first software analytics for websites, apps, and servers — no cookies on visitors by default, tracking sources, behavior, and conversions. | |
| FindUtils | 460+ free browser tools — converters, formatters, PDF tools, generators, and calculators with no signup and local-first browser processing. | |
| Emoji Favicons | Turn any of 3,773 Unicode emojis into an edge-hosted SVG, PNG, or ICO favicon with one <link> tag and a documented API. |
FindUtils and Emoji Favicons are not Laravel applications, so this package does not measure them. All five are maintained by the same author so you can see what else ships in production.
Licence
MIT.
Alternatives to olgunozoktas/laravel-page-performance
Lightweight profiler for PHP and Laravel. Add checkpoints, measure closures, tra...
Performance analysis toolkit for AI coding agents — SQL query profiling, N+1 det...
Inspect, profile and visualize every stage of the Laravel request lifecycle — fr...
Zero-config CI gate for Laravel: auto-instruments your test suite, baselines que...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v0.2.0 | ^8.3 | ^12.0| | MIT | |
| v0.1.4 | ^8.3 | ^12.0| | MIT | |
| v0.1.3 | ^8.3 | ^12.0| | MIT | |
| v0.1.2 | ^8.3 | ^12.0| | MIT | |
| v0.1.1 | ^8.3 | ^12.0| | MIT | |
| v0.1.0 | ^8.3 | ^12.0| | MIT |