PAM Browser
pushinbr/pam-browser is a small, typed Chrome DevTools Protocol (CDP) client for PHP applications running on PAM. It launches Chrome or Chromium as a supervised child process, connects to it over a WebSocket, and gives you pages you can navigate, evaluate JavaScript in, screenshot, and listen to.
There is no Node.js, npm, Puppeteer, or Playwright involved. The browser stays an external process; everything you write is PHP.
Use it when you need a real browser engine from a long-lived PHP process: rendering JavaScript-heavy pages, taking screenshots, or bridging a web app into PHP. It is also the browser layer under PAM WhatsApp Web, PAM Telegram Web, and the PAM Crawl browser plugin.
<?php
declare(strict_types=1);
require __DIR__.'/vendor/autoload.php';
use Pam\Browser\Browser;
$browser = Browser::launch();
try { $page = $browser->newPage('https://example.com');
echo $page->evaluate('document.title'), PHP_EOL;} finally { $browser->close();}Requirements
Section titled “Requirements”- The PAM runtime (see Installation). The package requires PHP 8.5 or newer, which PAM ships.
- Google Chrome or Chromium installed on the host. PAM Browser does not download a browser for you.
PAM Browser looks for an executable named google-chrome-stable, google-chrome, chromium, chromium-browser, or chrome on your PATH. Set the PAM_CHROME_PATH environment variable to point it somewhere else:
export PAM_CHROME_PATH=/opt/google/chrome/chromeInstallation
Section titled “Installation”Install the package with PAM’s Composer passthrough:
mkdir browser-demo && cd browser-demopam composer init --no-interactionpam composer require pushinbr/pam-browser:^1.0Your first page
Section titled “Your first page”Create title.php with the example from the introduction and run it:
pam title.phpExample DomainHere is what happened:
Browser::launch()started Chrome in headless mode with a temporary profile and a random local debugging port.newPage()created a new tab, attached a CDP session to it, and waited for theloadevent of the URL.evaluate()randocument.titlein the page and returned the value as a PHP string.close()asked Chrome to exit, closed the WebSocket, stopped the process, and deleted the temporary profile.
How it works
Section titled “How it works”your PHP code │ ▼PAM Browser ──── typed Browser and Page objects │ CDP over a local WebSocket (ws://127.0.0.1:<port>) ▼Chrome / Chromium (child process, headless by default)- Chrome is started with
--remote-debugging-address=127.0.0.1and--remote-debugging-port=0, so the debugging endpoint is bound to loopback on a free port. PAM Browser reads the actual endpoint from the profile’sDevToolsActivePortfile. - The WebSocket client is written in PHP and uses PAM’s native stream API (
Pam\Stream\Streams), so it does not depend on a third-party WebSocket library. - Commands are synchronous from your point of view:
evaluate()sends a command and waits for its response, routing any events that arrive in between to your listeners.
Next steps
Section titled “Next steps”- Launching Chrome: headless mode, persistent profiles, custom arguments.
- Pages & JavaScript: navigation, evaluation, screenshots, request control.
- Bindings & events: call PHP from JavaScript and run an event loop.
- Testing and the API reference.