Skip to content
NewPAM 2.2.27 is out

PHP, always
in memory.

PAM is a persistent PHP runtime written in Rust. Your Composer app boots once and stays warm, requests run in Fibers on async I/O, and the same PHP ships to servers, Laravel, Android, iOS and the desktop.

curl -fsSL https://pamphp.com/install | sh
  • Linux
  • macOS
  • Windows
  • Android
  • iOS
index.php
<?php
declare(strict_types=1);
use Pam\App;
$app = new App();
$app->get('/users/{id}', static fn ($request, $response) =>
$response->json([
'id' => $request->route('id'),
])
);
$app->listen(3000);
pam dev

An HTTP server in plain PHP. The app boots once and stays warm between requests.

Why PAM

The PHP you know, without the cold start.

PHP-FPM throws your application away after every request. PAM keeps it alive, so the work you already paid for (autoloading, config, containers, connections) is there for the next one.

  • Boot once, stay warm

    Your Composer app, framework container and OPcache stay in memory. Requests skip the bootstrap and go straight to your code.

  • A Fiber per request

    Every request runs in its own isolated Fiber. Async I/O suspends the Fiber instead of blocking the worker.

  • Supervised clusters

    Preforked workers share one OPcache, recycle after a request budget and are restarted by the supervisor when they crash.

  • Rust at the boundary

    Sockets, timers, TLS and HTTP/1.1, HTTP/2 and HTTP/3 run on Tokio. PHP runs through the embed SAPI, not a shim.

  • WebSockets built in

    Serve WebSockets from the same listener as HTTP, with backpressure handled by the runtime.

  • One toolchain

    pam init, pam dev, pam composer, pam artisan and pam doctor. No system PHP, no PHP-FPM, no Node.

Performance

Measured, not promised.

Same app, same machine, published protocol. Against FrankenPHP and OpenSwoole, PAM won 11 of 12 throughput scenarios.

Server

14 ms p99 latency

p99 latency, lower is better
p99 latency is 14 ms on PAM and 26 to 37 ms before prefork.PAM: 14 msPAM14 msBefore prefork: 26–37 msBefore prefork26–37 ms
Memory with 8 workers
With 8 workers PAM uses 167 MB; a per-process OPcache uses 535 MB.PAM, shared OPcache: 167 MBPAM, shared OPcache167 MBPer-process OPcache: 535 MBPer-process OPcache535 MB

Desktop · same POS app

11× faster launch than Electron

Cold start, lower is better
PAM Desktop launches in 138 ms; Electron takes 1,563 ms.PAM Desktop: 138 msPAM Desktop138 msElectron: 1,563 msElectron1,563 ms
Idle memory
PAM Desktop idles at 75 MB; Electron at 322 MB.PAM Desktop: 75 MBPAM Desktop75 MBElectron: 322 MBElectron322 MB

Crawl · 460 real pages

448 pages/s with 8 workers

Throughput, higher is better
pam-crawl does 448 pages per second with 8 workers and 141 to 152 in one process; crawl4ai does 7.9 in HTTP mode and 6.3 with a browser.pam-crawl, 8 workers: 448/spam-crawl, 8 workers448/spam-crawl, 1 process: 141–152/spam-crawl, 1 process141–152/scrawl4ai, HTTP: 7.9/scrawl4ai, HTTP7.9/scrawl4ai, browser: 6.3/scrawl4ai, browser6.3/s
Peak memory, lower is better
Peak RAM is 94 MB for pam-crawl in one process, 525 MB for crawl4ai in HTTP mode and 3,774 MB with a browser.pam-crawl, 1 process: 94 MBpam-crawl, 1 process94 MBcrawl4ai, HTTP: 525 MBcrawl4ai, HTTP525 MBcrawl4ai, browser: 3,774 MBcrawl4ai, browser3,774 MB

Server: Laravel on the benchmark protocol. Desktop: a 37-screen point-of-sale app rewritten from Electron. Crawl: crawl4ai 0.9.6, whole process tree measured, Core Ultra 9 185H (method).

Ecosystem

Packages that assume memory.

Install with pam composer require pushinbr/…. Every package is open source and published on Packagist.

Browse the ecosystem

Quick start

Start in 60 seconds.

  1. Install PAM

    One binary in ~/.local/bin. It brings its own PHP and Composer.

    curl -fsSL https://pamphp.com/install | sh
  2. Create an app

    Pick a template: http, laravel, native-ui or desktop.

    pam init my-api --template http
  3. Run it

    The dev server watches your code and reloads on save. pam doctor checks your setup.

    cd my-api && pam dev

Ready when you are.

Read the guide, or go straight to the code.