Install & CI

Commands for installing Playwright PHP, browser binaries, and system dependencies, with GitHub Actions setup and browser cache configuration.

PlaywrightPHP Install & CI
playwright-php.dev

Install

Command What it does
composer require --dev playwright-php/playwright The library and its Node server
vendor/bin/playwright-install chromium Playwright-managed Chromium only
vendor/bin/playwright-install chromium webkit The selected browser targets
vendor/bin/playwright-install --browsers Chromium, Firefox, WebKit binaries
vendor/bin/playwright-install --with-deps chromium Chromium plus OS packages: CI, Docker, fresh Linux
vendor/bin/playwright-install --dry-run --with-deps chromium Preview, changes nothing
~/.cache/ms-playwright Where the browsers land
PLAYWRIGHT_BROWSERS_PATH=/path Point at an existing cache

Tip. Node 20+ does the driving. The server starts on demand; there is nothing to keep running.

GitHub Actions

Step Why
uses: playwright-php/setup-playwright@v1 with browsers: chromium Playwright npm runtime, managed Chromium, Linux OS dependencies
uses: shivammathur/setup-php@v2 Manual route: PHP on the runner
uses: actions/setup-node@v4 Node 20+ for the driver
run: composer install --no-interaction PHP dependencies
run: vendor/bin/playwright-install --with-deps chromium Managed Chromium plus system libraries
run: vendor/bin/phpunit --colors=always The suite, browsers included
uses: actions/upload-artifact@v4 On failure(): keep traces and screenshots

Gotcha. --browsers downloads all three managed browsers but no OS packages. Fresh Linux runners also need --with-deps. Add a target such as chromium when the job uses only one browser.

Cache & speed

Setting Effect
uses: actions/cache@v4 Restore browsers between runs
path: ~/.cache/ms-playwright What to cache
key: playwright-${{ hashFiles('composer.lock') }} Rotate when dependencies change
vendor/bin/phpunit --exclude-group integration Fast lane: everything but the browser tests
timeout-minutes: 20 Cap a hung run
PW_TRACE=1 Record a trace, upload it on failure

Tip. Test the oldest supported PHP plus the one you develop on. Chromium on every PR; Firefox and WebKit on nightly.

Fast path

composer require --dev playwright-php/playwright && vendor/bin/playwright-install --with-deps chromium

Action step

yaml
- uses: playwright-php/setup-playwright@v1
  with:
    browsers: chromium

Deeper reads

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