We drive Chrome over the DevTools Protocol from PHP: how the pieces fit, what the API covers today, and where its limits are.
Most teams that automate WhatsApp Web end up with the same setup. The app is PHP, but next to it sits a Node.js service running whatsapp-web.js and Puppeteer, and the two talk over HTTP or a queue. whatsapp-web.js is a solid library. Still, you now deploy, monitor and upgrade two runtimes to send a message.
We wanted one runtime. Not PHP calling a Node script, but a PHP process that owns the WhatsApp session, receives events and sends messages itself. That library is pam-whatsapp-web. Below is how it works, a listener you can run, what the API covers and what it doesn't.
The problem is process lifetime, not the language
A WhatsApp Web client has to stay up for as long as the session does. It keeps a browser open, listens for events and reacts as they arrive.
Classic PHP doesn't work that way. A request starts, runs and ends, and nothing stays in memory afterwards. That is the real reason the long-running part usually moves to Node.
PAM is a native runtime for PHP, and it can keep a PHP process alive. Once the process stays up, the WhatsApp client can live inside it.
How the stack fits together
There are three layers:
| Layer | Package | Job |
|---|---|---|
| Runtime | PAM | Keeps the PHP process alive |
| Browser driver | PAM Browser (pushinbr/pam-browser ^1.0) | Drives Chrome or Chromium over the Chrome DevTools Protocol |
| Client | pushinbr/pam-whatsapp-web | Typed API: client, events, messages, media, groups and more |
In production there is no Node.js, npm, Puppeteer or Playwright. PHP talks to the browser directly over CDP.
Setup
You need:
- PAM installed. If it's new to you, install it from the main repository and run
pam doctorfirst. - Chrome or Chromium on the host.
Then create a project and add the library:
pam init my-whatsapp --template raw cd my-whatsapp pam composer require pushinbr/pam-whatsapp-web One thing that trips people up: PAM doesn't put a php binary on your PATH. Run scripts with pam script.php and Composer with pam composer ....
Before going further, keep the session folder out of git. The example below stores credentials in .sessions/:
echo '.sessions/' >> .gitignore A message listener
Save this as listen.php:
<?php declare(strict_types=1); require __DIR__.'/vendor/autoload.php'; use Pam\WhatsApp\Auth\LocalAuth; use Pam\WhatsApp\Auth\LocalAuthOptions; use Pam\WhatsApp\Client; use Pam\WhatsApp\ClientOptions; use Pam\WhatsApp\Event\MessageReceived; use Pam\WhatsApp\Event\QrCodeReceived; use Pam\WhatsApp\Event\Ready; use Pam\WhatsApp\TerminalQrCode; $client = new Client(new ClientOptions( authStrategy: new LocalAuth(new LocalAuthOptions( clientId: 'main', dataPath: __DIR__.'/.sessions', )), )); $client->onQrCode(static function (QrCodeReceived $event): void { echo "\n\nOpen WhatsApp > Linked devices > Link a device\n\n"; echo TerminalQrCode::render($event->code), "\n"; }); $client->onReady(static function (Ready $event): void { echo "\n\n✓ WhatsApp connected. Waiting for messages...\n"; }); $client->onMessage(static function (MessageReceived $event): void { $message = $event->message; $body = $message->body !== '' ? $message->body : '['.$message->type->name.']'; printf("[%s] %s: %s\n", date('H:i:s', $message->timestamp), $message->from, $body); }); $client->initialize(); $client->run(); Run it:
pam listen.php Here's what happens:
- The first time, a QR code shows up in the terminal.
- In WhatsApp, go to Linked devices and scan it.
- The client connects and starts printing incoming messages. If a message has no text body (an image, say), it prints the type name in brackets.
- Stop it and run it again. The session is restored from
.sessions/, so no new QR code this time.
If you've used whatsapp-web.js, this should look familiar: a client, an auth strategy, initialize() and event callbacks. The full runnable program is in examples/listen.php in the repository.
What the API covers
We're aiming for parity with whatsapp-web.js. The current reference is version 1.34.7, commit 942d236, tracked in api-matrix.json.
- Session: QR, pairing code,
LocalAuth,RemoteAuth, reconnection and session conflict handling. - Messages: text, replies, editing, deletion, forwarding, reactions, mentions and read receipts.
- Media: images, audio, video, documents, stickers, thumbnails and streaming downloads.
- Conversations: contacts, private chats, groups, participants, invites and membership requests.
- Content: locations, polls, contacts, contact lists, scheduled events and legacy buttons/lists.
- WhatsApp: presence, connection state, calls, channels, labels, business profiles, products and orders.
LocalAuth keeps the session on disk, like the example does. RemoteAuth is there too. The repository has a cookbook of supported features and a Compatibility section backed by api-matrix.json.
PHP types, not JavaScript objects copied over
We didn't want an API built on loose arrays. So:
- Typed objects.
$event->messageis a class, not an array. - Integer-backed enums.
$message->typeis an enum, which is why->nameworks in the example. - Immutable events.
- PHPStan level 9.
- An automated parity matrix against
whatsapp-web.js, so we can see which parts of the reference API exist on our side.
In practice, your IDE autocompletes the API and static analysis catches mistakes before they run.
Limitations
Read this before you plan anything around the library.
Chrome still runs. We dropped Node.js and Puppeteer, not the browser. Chrome or Chromium has to be installed on the host, and PAM Browser drives it. We haven't published memory or CPU numbers for this setup yet, so measure it on your own hardware.
PHP 8.5+ on PAM only. It needs PHP 8.5 with ext-mbstring, and it depends on PAM to keep the process alive. You can't drop it into a classic one-process-per-request deployment.
Parity is pinned to a version. The reference is whatsapp-web.js 1.34.7. Anything added upstream after that commit isn't covered until we update the matrix.
Buttons and lists are deprecated. whatsapp-web.js marks them as not working. We keep the PHP types only so existing code still compiles, and delivery is not guaranteed. Don't build a new flow on them.
The session folder is a credential. Whoever has .sessions/ has your linked device. Don't commit it, publish it or share what's in it. Treat it like a password.
Use it responsibly. The repository has a Responsible use section. Read it before you automate anything that messages real people.
Links
If you try it and something breaks, or a whatsapp-web.js feature you need is missing, open an issue. And if it's useful to you, a star helps other PHP developers find it.
- pam-whatsapp-web: github.com/push-in/pam-whatsapp-web
- PAM Browser: github.com/push-in/pam-browser
- PAM: github.com/push-in/pam
- PAM Native, the same runtime for Android and iOS apps: github.com/push-in/pam-native


