GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - playwright-php/performance: Measure Core Web Vitals and browser performance timings from PHP

BranchesTags
Open more actions menu

Latest commit

 

History

9 Commits
9 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
resources/js
resources/js
 
 
src
src
 
 
tests
tests
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.php-cs-fixer.dist.php
.php-cs-fixer.dist.php
 
 
LICENSE
LICENSE
 
 
NOTICE
NOTICE
 
 
README.md
README.md
 
 
composer.json
composer.json
 
 
phpstan.dist.neon
phpstan.dist.neon
 
 
phpunit.dist.xml
phpunit.dist.xml
 
 

Repository files navigation

Playwright PHP

  PHP Version   CI   Release   License

Playwright PHP Performance

Collect Core Web Vitals and resource timing data from pages opened with Playwright PHP.

Installation

composer require --dev playwright-php/performance
vendor/bin/playwright-install --browsers

The package requires PHP 8.2+ and Playwright PHP 1.x.

Quick Start

Navigate to a page, collect its metrics, and generate a report:

<?php

require __DIR__.'/vendor/autoload.php';

use Playwright\Performance\Monitor\PerformanceMonitor;
use Playwright\Performance\Reporter\JsonReporter;
use Playwright\Playwright;

$context = Playwright::chromium();
$page = $context->newPage();
$monitor = new PerformanceMonitor($page);

$monitor->navigate('https://example.com');

$vitals = $monitor->collectCoreWebVitals();
$resources = $monitor->collectResourceMetrics();
$report = (new JsonReporter())->generate($vitals, $resources);

file_put_contents('performance.json', $report);

$context->close();

CoreWebVitals exposes LCP, FCP, CLS, INP, FID, TTFB, and TBT as public readonly properties and through getter methods.

Each ResourceMetrics value contains the URL, resource type, duration, transfer size, and detailed network timing values.

PHPUnit Assertions

Use PerformanceAssertions with the core Playwright test case to enforce broad, stable budgets:

use Playwright\Performance\Monitor\PerformanceMonitor;
use Playwright\Performance\Test\PerformanceAssertions;
use Playwright\Testing\PlaywrightTestCase;

final class HomepagePerformanceTest extends PlaywrightTestCase
{
    use PerformanceAssertions;

    public function testHomepageBudgets(): void
    {
        $monitor = new PerformanceMonitor($this->page);
        $monitor->navigate('https://example.com');

        $vitals = $monitor->collectCoreWebVitals();
        $resources = $monitor->collectResourceMetrics();

        $this->assertLcpBelowThreshold($vitals, 2500);
        $this->assertClsBelowThreshold($vitals, 0.1);
        $this->assertResourceCountBelowThreshold($resources, 50);
    }
}

Shared CI runners vary. Use budgets that detect meaningful regressions instead of asserting exact timings.

Reports

JsonReporter produces structured JSON. MarkdownReporter produces a readable summary with Core Web Vitals and the slowest resources.

use Playwright\Performance\Reporter\MarkdownReporter;

$markdown = (new MarkdownReporter())->generate($vitals, $resources);
file_put_contents('performance.md', $markdown);

Testing Without a Browser

MockPerformanceMonitor implements the same interface as the browser-backed monitor:

use Playwright\Performance\Metrics\CoreWebVitals;
use Playwright\Performance\Monitor\MockPerformanceMonitor;

$monitor = new MockPerformanceMonitor();
$monitor->setCoreWebVitals(new CoreWebVitals(
    lcp: 1000.0,
    fcp: 500.0,
    cls: 0.05,
    inp: 0.0,
    fid: 0.0,
    ttfb: 100.0,
    tbt: 0.0,
));

Limits

  • Automated browser metrics are laboratory data, not real-user monitoring.
  • INP and FID require user interaction and may remain zero in page-load tests.
  • Browser and runner variance can make narrow timing thresholds unreliable.

Documentation

  • Playwright PHP Getting Started

Contributing

Contributions are welcome. Before submitting a pull request, run:

composer validate --strict
vendor/bin/php-cs-fixer fix --dry-run --diff
vendor/bin/phpstan analyse
vendor/bin/phpunit

License

Playwright PHP Performance is released under the MIT License.

About

Measure Core Web Vitals and browser performance timings from PHP

playwright-php.dev

Topics

browsercore-web-vitalsnetworkperformancephp-browserplaywrightplaywright-phptestingtimingweb-performance

Resources

Readme
MIT license

Code of conduct

Code of conduct

Security policy

Security policy
Activity
Custom properties

Stars

0 stars

Watchers

0 watching

Forks

1 fork
Report repository

Releases

Sponsor this project

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.