Command line

Install, run, switch engine, and watch the browser, from the shell.

PlaywrightPHP Command line
playwright-php.dev

Install

Command What it does
composer require --dev playwright-php/playwright Adds the library and its Node server
vendor/bin/playwright-install chromium Downloads Playwright's managed Chromium build
vendor/bin/playwright-install chromium webkit Downloads selected browser targets
vendor/bin/playwright-install --browsers Downloads Chromium, Firefox, WebKit
vendor/bin/playwright-install --with-deps chromium Downloads Chromium and installs its system libraries
vendor/bin/playwright-install --dry-run --with-deps chromium Shows what it would do, and does nothing

Run

Command What it does
php content/examples/visit.php Runs a plain script
vendor/bin/phpunit Runs everything, browsers included
vendor/bin/phpunit --exclude-group integration Runs everything but the browser tests

Environment

Variable Effect
PW_HEADLESS=false Shows the browser instead of hiding it
PW_BROWSER=firefox Switches engine for the run
PW_SLOWMO_MS=250 Slows every action down
PW_TRACE=1 Records a trace
PLAYWRIGHT_BROWSERS_PATH=/path Points at an existing browser cache

The core prefix is PW_. PLAYWRIGHT_E2E and PLAYWRIGHT_HEADLESS belong to the Symfony bundle and do nothing here.

Watch a run

bash
PW_HEADLESS=false vendor/bin/phpunit

On CI, do the opposite. Keep it headless and record a trace instead: you get the whole run back as an artifact, with no display attached. See record a trace.

When it will not start

Symptom Cause
command not found: vendor/bin/playwright-install Composer has not installed the package, or you are not at the project root
A browser fails to launch on Linux System libraries are missing. Re-run with --with-deps

Deeper reads

PHP 8.2+ · MIT · playwright-php.dev/cheatsheets/cli Not affiliated with Microsoft