Skip to content

PAM Octane

pushinbr/pam-octane adds pam as a Laravel Octane server, next to Swoole, FrankenPHP and RoadRunner. Octane keeps ownership of the Laravel lifecycle (the real Laravel\Octane\Worker, its request sandbox, events and listeners), while PAM provides the embedded PHP, the Rust networking stack, streaming, supervision and zero-downtime reloads.

HTTP → PAM / Tokio → PamClient → Octane Worker → Laravel

It works with stock laravel/octane; no fork is needed. This page is the package reference. For running Laravel on PAM in general (with or without Octane), deployment and observability, see the Laravel section.

In a Laravel 12 or 13 application:

Terminal window
pam composer require laravel/octane pushinbr/pam-octane
php artisan octane:install --server=pam

octane:install --server=pam looks for the pam binary on PATH, in the project root or in ~/.local/bin. If it is missing, it offers to install it with PAM’s official install script, which verifies the release checksum. It then writes OCTANE_SERVER=pam to .env and publishes config/octane.php, as for any Octane server.

Requirement Version
Laravel 12.x or 13.x
laravel/octane 2.19 or newer
PHP (host, for php artisan) 8.4 or 8.5, with pcntl
PAM 2.2.15 or newer for --server=pam

PAM always runs your application on its own embedded PHP 8.5; the host PHP only runs Artisan. PAM supports Linux and macOS; on Windows, use WSL 2 or Docker.

Terminal window
php artisan octane:start # OCTANE_SERVER=pam, or --server=pam
php artisan octane:reload # replace every worker without dropping requests
php artisan octane:status
php artisan octane:stop

octane:start accepts Octane’s usual options: --host, --port, --workers, --task-workers, --max-requests, --watch and --poll. It runs a foreground pam start cluster, logs each request in the local environment and stops on Ctrl+C. This mode suits systemd, Supervisor and container entrypoints.

Every Artisan command also runs through PAM’s PHP as pam artisan octane:start and so on.

Octane’s own configuration applies: octane.max_execution_time, octane.max_requests, octane.tables, octane.cache, octane.serve_static_files and octane.static_file_headers. For PAM-specific limits, publish the package configuration:

Terminal window
php artisan vendor:publish --tag=pam-octane-config

The most common environment variables:

Variable Default Description
PAM_HOST, PAM_PORT 127.0.0.1, 8000 Listener address.
PAM_REQUEST_TIMEOUT_MS octane.max_execution_time Request deadline; a request past it gets 504 and its worker is replaced. 0 disables it.
PAM_MAX_BODY_BYTES 2097152 Largest body held in memory (JSON, forms). Multipart uploads stream to disk instead.
PAM_MAX_RESPONSE_BYTES 268435456 Largest response.
PAM_SERVE_STATIC_FILES true Serve files from public/ with ETag and Range support.
PAM_OCTANE_SHARED_CACHE unset Share the octane cache store across workers even without task workers.
PAM_PREFORK_BOOT unset app boots Laravel once and forks every worker from it (Linux; pam octane:start does this by default); engine boots Laravel in every worker.
PAM_RESPONSE_CACHE false Enable the edge page cache.
PAM_TLS_CERT, PAM_TLS_KEY unset Serve TLS directly.

The published config/pam-octane.php lists every option, including header limits, streaming queues, garbage collection intervals, route metrics and the page cache settings.

Features that Octane otherwise offers only on Swoole work on PAM:

  • Tables. Tables declared in octane.tables live in shared memory: every worker sees the same rows and they survive reloads. Octane::table('name') returns the PAM table, so Swoole code runs unchanged; Pam\Octane\PamOctane::table('name') is equivalent. Values larger than their column throw, as on Swoole.
  • The octane cache store. Cache::store('octane') and Cache::interval() are shared by every worker when task workers run, or when PAM_OCTANE_SHARED_CACHE=true.
  • Concurrent tasks and ticks. Start task workers with --task-workers=N (or auto, one per CPU) to run Octane::concurrently(), task dispatch, Octane::tick() and cache intervals. Without task workers, tasks run sequentially, as on RoadRunner and FrankenPHP.

PAM also streams uploads to temporary files (so a 1 GB upload works with the default memory_limit), replaces workers make-before-break on octane:reload and --max-requests, and keeps listening sockets in the master so no queued connection is dropped.

With PAM_RESPONSE_CACHE=true, PAM can serve whole pages from Rust without entering PHP. Mark cacheable routes with the CacheResponse middleware and remove the stateful middleware, because PAM never stores a response that sets cookies:

routes/web.php
use Pam\Octane\Http\Middleware\CacheResponse;
Route::get('/products/{product}', ShowProduct::class)
->middleware(CacheResponse::for(ttl: 600, staleWhileRevalidate: 60, tags: ['products', 'product:{product}']))
->withoutMiddleware(CacheResponse::STATEFUL);

The middleware is also aliased as pam.cache (pam.cache:600,60,products). Only GET and HEAD responses with a cacheable status are marked. {parameter} in a tag is replaced by the route parameter. By default, requests with a Cookie or Authorization header are never served from the cache.

Purge from your code with the facade:

use Pam\Octane\Facades\Pam;
Pam::purge('products');
Pam::purgeUrl('https://example.com/products/42');
Pam::purgeAll();

Or let Eloquent models purge their pages when they change:

app/Models/Product.php
use Pam\Octane\Cache\PurgesPageCache;
class Product extends Model
{
use PurgesPageCache; // purges "products" and "products:{id}" after commit
}

Override pageCacheTags() to purge other tags. From the command line, use pam cache:purge.

For a supervised cluster with crash recovery, health checks and generational reloads, run Artisan as the worker entrypoint:

Terminal window
pam start artisan \
--workers 8 \
--max-requests 100000 \
--admin-address 127.0.0.1:3010 \
-- pam:octane --host=0.0.0.0 --port=8000

Or run Octane’s command in the foreground under systemd, Supervisor or a container:

Terminal window
OCTANE_SERVER=pam PAM_PREFORK_BOOT=app php artisan octane:start \
--host=0.0.0.0 --port=8000 --workers=8 --max-requests=100000

Workloads with different latency or memory profiles can run in isolated pools behind PAM’s ingress:

Terminal window
pam octane:start \
--ingress-address=0.0.0.0:8000 \
--pool=api=8@/api,/graphql \
--pool=web=4@* \
-- --host=0.0.0.0 --port=8000

Exactly one * fallback pool is required. Queue workers, Horizon and the scheduler stay separate supervised processes. Never expose the admin listener publicly. With PAM_PREFORK_BOOT=app, database and Redis connections opened during boot are closed before forking; register \Pam\Fork::beforeFork() and \Pam\Fork::afterFork() callbacks for anything else that must be reset per process.

See Deploy Laravel for complete deployment guides.

Run these from the Laravel project root before opening an issue:

Terminal window
pam --version
pam doctor
pam artisan about
php artisan octane:status --server=pam
  • “PAM runtime is missing”. Run Artisan through pam artisan, or use pam octane:start.
  • Memory grows over time. Reproduce with one worker and look for request state kept in singletons before lowering --max-requests.
  • Requests stall. Look for blocking PDO, filesystem, HTTP or extension calls; move them to task workers or add workers.

Version 1.4 has no breaking changes. It adds php artisan octane:start --server=pam and the other Octane commands with stock laravel/octane. If you used the push-in/octane fork, remove its repository entry (or laravel/octane: dev-2.x-pam) from composer.json and require laravel/octane ^2.19. PamOctane::table() and the pam octane:* commands keep working.

pushinbr/pam-octane is licensed under the Apache License 2.0.