pam-browser: A typed Chrome DevTools Protocol client for PHP on PAM. No Node.js, no Puppeteer. **Drive Chrome and Chromium from typed PHP, straight over the DevTools Protocol.**
PAM supervises the browser process and speaks CDP over its own WebSocket transport. Node.js, npm, Puppeteer and Playwright are never installed. [![Packagist](https://img.shields.io/packagist/v/pushinbr/pam-browser?label=packagist&color=f53003)](https://packagist.org/packages/pushinbr/pam-browser) [![Latest release](https://img.shields.io/github/v/release/push-in/pam-browser?label=release&color=e3a008)](https://github.com/push-in/pam-browser/releases/latest) ![PHP 8.5](https://img.shields.io/badge/php-8.5-777bb4) [![License](https://img.shields.io/github/license/push-in/pam-browser?color=1f6feb)](LICENSE) [Documentation](https://pamphp.com/packages/browser/) · [Install](#install) · [Quick example](#quick-example) · [What it covers](#what-it-covers) · [Docs](#docs) · [Issues](https://github.com/push-in/pam-browser/issues)
## Install Create a PAM project and add the browser client: ```sh pam init my-app --template raw cd my-app pam composer require pushinbr/pam-browser ``` Install Chrome or Chromium separately on the host. PAM Browser supervises that external process and speaks CDP directly; no Node.js or browser-automation wrapper is installed. New to PAM? Start with the [PAM introduction](https://pamphp.com/introduction/). ## Quick example Launch Chromium, evaluate JavaScript in a page and receive data back in PHP through a binding. Save it as `browser.php` and run `pam browser.php`. ```php version()['product'] ?? 'unknown'; $page = $browser->newPage('data:text/html,PAM Browser'); echo $page->evaluate('document.title'), "\n"; // PAM Browser $page->exposeBinding('fromPage', static function (mixed $payload): void { var_dump($payload); // ['bridge' => 'ready'] }); $page->evaluate('globalThis.fromPage(JSON.stringify({bridge: "ready"}))'); $page->pump(1.0); printf("Connected to %s, target %s\n", $product, $page->targetId); } finally { $browser->close(); } ``` Adapted from [`tests/integration/chromium.php`](tests/integration/chromium.php), the live Chromium gate. `Browser::launch()` accepts `Pam\Browser\Chromium\LaunchOptions` (executable, user data directory for a persistent profile, headless, timeout, extra arguments). ## Platform support | Platform | Support | Notes | | --- | --- | --- | | PAM runtime host | Chrome or Chromium installed | Found on `PATH` (`google-chrome-stable`, `google-chrome`, `chromium`, `chromium-browser`, `chrome`), or set `PAM_CHROME_PATH` / `LaunchOptions::executable` | | PHP | 8.5+ | From `composer.json` | ## What it covers | Layer | Classes | | --- | --- | | Protocol codec and event routing | `Protocol\Command`, `Protocol\Response`, `Protocol\Event`, `Connection` (`command`, `on`, `waitForEvent`, `pump`) | | PAM-native WebSocket transport | `Transport\WebSocketTransport`, `WebSocket\FrameCodec` (no third-party WebSocket dependency) | | Supervised Chrome/Chromium lifecycle | `Chromium\BrowserProcess`, `Chromium\LaunchOptions`, `Chromium\ExecutableLocator`, persistent profiles | | Browser and pages | `Browser` (`launch`, `version`, `newPage`, `createTarget`, `close`), `Page` (`navigate`, `evaluate`, `waitForFunction`, `exposeBinding`, `addScriptOnNewDocument`, `captureScreenshot`, `setUserAgent`, `authenticate`, `serveDocument`, `captureDocument`) | The browser itself remains an external Chrome/Chromium process. JavaScript may be evaluated inside a page, while the application API and orchestration remain strictly typed PHP. PAM Browser is the browser boundary used by [PAM WhatsApp Web](https://github.com/push-in/pam-whatsapp-web). ## Verification ```sh pam composer analyse # PHPStan level 9 pam composer test # PHPUnit pam composer test:integration # live Chromium gate: pam tests/integration/chromium.php ``` ## Docs - [PAM introduction](https://pamphp.com/introduction/) - [Packages overview](https://pamphp.com/packages/overview/) - [Changelog](CHANGELOG.md) - [Report an issue](https://github.com/push-in/pam-browser/issues) ## Part of the PAM ecosystem

PAM

PAM runs PHP natively on servers, desktops and phones. This repository is one piece of it. | [**PAM**](https://github.com/push-in/pam) | [**PAM Desktop**](https://github.com/push-in/pam-desktop) | [**PAM Native**](https://github.com/push-in/pam-native) | [**Ecosystem**](https://github.com/push-in/pam#ecosystem) | | --- | --- | --- | --- | | the runtime and CLI | native desktop apps in PHP | native Android and iOS apps in PHP | every official package and plugin | Docs: [pamphp.com](https://pamphp.com/introduction/) · [Issues](https://github.com/push-in/pam-browser/issues)

Apache License 2.0 · Made in Brazil by Pushin