Install Playwright PHP

Add the Composer package, install browser binaries, and verify that Chromium can start.

Install the PHP package first, then download the browser targets your project runs.

Requirements

Check your tools:

bash
php --version
node --version
composer --version

You need PHP 8.2 or newer, Node.js 20 or newer, and Composer. Node.js runs the bundled Playwright server; you do not write Node code.

Install the package

From your project root:

bash
composer require --dev playwright-php/playwright

Expected result: Composer adds the package and creates or updates vendor/.

Install browsers

bash
vendor/bin/playwright-install chromium

Expected result: Playwright's managed Chromium build is downloaded into the browser cache.

Install all three managed browsers when the project runs a cross-browser suite:

bash
vendor/bin/playwright-install --browsers

This downloads Chromium, Firefox, and WebKit.

On a fresh Linux machine or CI runner, use:

bash
vendor/bin/playwright-install --with-deps chromium

Check the install

Create hello.php:

php
<?php

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

use Playwright\Playwright;

$page = Playwright::chromium()->newPage();
$page->goto('https://example.com');

echo $page->title(), "\n";

Run it:

bash
php hello.php

Expected result:

text
Example Domain

If it fails

  • vendor/bin/playwright-install: command not found: run composer require --dev playwright-php/playwright from the project root.
  • Browser launch fails on Linux: run vendor/bin/playwright-install --with-deps chromium.
  • Node is too old: install Node.js 20 or newer, then rerun the browser install.

Next: Run your first script.