Skip to content

Configuration Reference

PAM reads configuration from four places:

Where What it configures
pam.json The project: its type, name, version, custom commands and pam deploy:remote defaults
The third argument of listen() The HTTP/WebSocket server of each worker: limits, TLS, proxies, metrics, cache
pam.toml Applications managed declaratively by pam plan and pam apply
PHP INI files and -d flags The embedded PHP engine

CLI flags (see CLI Reference) and environment variables (see Environment Variables) complete the picture. For a guided introduction, start with Configuration.

Every PAM project has a pam.json at its root. pam init writes it, and pam doctor --fix recreates a missing one:

pam.json
{
"$schema": "https://push-in.github.io/pam-docs/schemas/pam.schema.json",
"name": "acme-api",
"schema": 1,
"type": 1,
"version": "0.1.0"
}
Key Type Required Description
$schema string no JSON Schema URL for editor validation
schema integer yes Always 1
type integer yes 1 API, 2 Native, 3 Laravel, 4 Desktop, 5 raw runtime, 6 Product workspace
name string yes 1 to 80 characters
version string no SemVer (1.2.3 or 1.2.3-beta.1), up to 64 characters; used in package names
native object for Native apps applicationId, starter (1 blank, 2 tabs, 3 authentication, 4 e-commerce, 5 chat, 6 showcase) and platforms (1 Android, 2 iOS, 3 Android TV)
workspace object for type 6 surfaceCodes ([1, 2, 3]: server, native, desktop) and contractPath (packages/contracts)
deploy object no Defaults for pam deploy:remote (below)
commands object no Project commands run as pam <name> (below)

The schema rejects unknown keys.

Key Type Description
host string user@host for SSH
path string Release root; absolute or relative to the remote home (default pam-apps/<name>)
name string Process-manager name (1 to 64 characters)
workers integer Workers of the first pam up
healthCheckUrl string http:// readiness URL of the first pam up
keep integer Releases kept on the server, 1 to 100 (default 5)
pam string The pam executable on the server (default pam)

Command-line options of pam deploy:remote win over these values.

Each key (lowercase letters, digits, :, _, -) becomes pam <key> inside the project. A value is either a script path, or an object with either script or bin, optional arguments (up to 32 strings) and an optional description:

pam.json
{
"commands": {
"migrate": "bin/migrate",
"report:daily": {
"script": "bin/report.php",
"arguments": ["--period=daily"],
"description": "Build the daily report"
}
}
}

See Package Commands for how packages register their own commands.

Pass server options as the third argument of listen():

Server::create($handler)->listen(3000, '127.0.0.1', [
'requestTimeoutMs' => 10_000,
'trustedProxies' => ['10.0.0.0/8'],
]);

Unknown keys are ignored, but every known key is type-checked: integers must be positive unless the table says 0 is allowed, and an invalid value throws InvalidArgumentException at boot. The port must be 1 to 65535 and the host cannot be empty.

Option Type Default Description
maxBodyBytes int 2097152 (2 MiB) Largest body kept in memory (JSON, forms, raw). Not applied to multipart uploads
maxInflightBodyBytes int, 0 allowed memory_limit / 4 Body bytes one worker may hold at once; 0 disables
maxHeaderBytes int 32768 Total header size
maxHeaders int 100 Number of headers
headerReadTimeoutMs int 10000 Deadline to receive the headers
bodyReadTimeoutMs int 30000 Deadline to receive the body
requestTimeoutMs int 30000 Hard request deadline: 504 and the worker is recycled
maxConcurrentRequests int 4096 Requests (Fibers) a worker runs at once
maxConnections int, 0 allowed 0 Open connections per worker; 0 means the open file limit minus 256
phpExecutorQueueCapacity int 1024 Requests queued for the PHP thread
rateLimitPerSecond int, 0 allowed 0 Per-client token bucket per worker; 0 disables
Option Type Default Description
maxResponseBytes int 268435456 (256 MiB) Largest response
maxResponseChunkBytes int 1048576 (1 MiB) Largest streamed chunk; cannot exceed maxResponseBytes
responseStreamQueueCapacity int 16 Chunks buffered per streamed response
Option Type Default Description
trustedProxies string list [] Addresses or CIDR ranges allowed to set forwarding headers; * trusts every peer (warns at boot). PAM_TRUSTED_PROXIES adds more
corsOrigins string list [] Allowed CORS origins
tlsCert string or null null PEM certificate file
tlsKey string or null null PEM private key file
http3 bool true Serve HTTP/3 over QUIC when TLS is configured
http2MaxConcurrentStreams int 256 Streams per HTTP/2 connection
http2StreamWindowBytes int 1048576 Initial flow-control window per stream
http2ConnectionWindowBytes int 4194304 Flow-control window per connection
Option Type Default Description
exposeErrors bool false Put exception messages in 500 responses and leave display_errors untouched. Never enable in production
accessLog bool false One JSON line per request on stderr
accessLogSampleRate int 1 Log one request in N
telemetryHeaders bool false Add x-request-id, traceparent and Server-Timing to responses
metricsPath string /metrics Worker metrics path
metricsToken string or null null Require Authorization: Bearer <token> from any peer (PAM_METRICS_TOKEN)
metricsPublic bool false Serve metrics to any peer without a token (PAM_METRICS_PUBLIC=1)
routeMetrics bool false Per-route metrics
routeMetricsMaxEntries int 256 Bound on distinct routes tracked
Option Type Default Description
gcCollectCyclesEvery int, 0 allowed 256 Run gc_collect_cycles() every N requests
gcMemCachesEvery int, 0 allowed 1024 Run gc_mem_caches() every N requests
leakDetectionSampleRate int, 0 allowed 1024 Sample one request in N for leak detection
leakThresholdBytes int 8388608 (8 MiB) Memory growth reported as a possible leak

See Memory & State.

Option Type Default Description
websocketOrigins string list [] Browser origins allowed to connect (* for any); empty falls back to corsOrigins. PAM_WEBSOCKET_ORIGINS overrides
websocketMaxConnections int 10000 Connections per worker
websocketMaxMessageBytes int 1048576 Largest message
websocketQueueCapacity int 256 Outbound messages queued per connection
websocketHeartbeatMs int 15000 Ping interval
websocketTimeoutMs int 45000 Idle timeout
websocketCompression bool true Per-message compression
websocketResumeSecret string or null null Secret that signs resume tokens; keep it in a secret store
websocketResumeTtlSeconds int 86400 Lifetime of a resume token

See WebSockets.

Option Type Default Description
responseCache bool false Store any GET/HEAD response that opts in with Cache-Control: public, s-maxage=N
responseCachePaths absolute path list [] Paths eligible for caching
responseCacheTtlMs int 30000 Default TTL when a cached response does not set one
responseCacheStaleWhileRevalidateMs int, 0 allowed 0 Serve stale while refreshing
responseCacheMaxEntries int 1024 Entries kept
responseCacheMaxBytes int 67108864 (64 MiB) Total size
responseCacheMaxObjectBytes int 8388608 (8 MiB) Largest cached response
responseCacheMaxTtlMs int 604800000 (7 days) Upper bound for s-maxage
responseCacheStatuses int list [200, 203, 204, 300, 301, 308, 404, 410] Cacheable status codes
responseCacheVaryHeaders string list [] Extra headers in the cache key
responseCacheIgnoredQueryParams string list [] Query parameters left out of the key
responseCacheAllowCookies bool false Allow caching requests with cookies
responseCacheAllowAuthorization bool false Allow caching requests with Authorization
responseCacheCompress bool true Store compressed copies
responseCacheStatusHeader bool true Add a cache status header
responseCacheTagHeader string x-pam-cache-tags Response header carrying purge tags
responseCachePurgePath string or null null HTTP purge endpoint
responseCachePurgeSecret string or null null Bearer secret of the purge endpoint
responseCacheInvalidationLog string or null null File watched for pam cache:purge entries

See Shared Memory & Caching.

Multipart uploads follow PHP’s own INI settings, not a listen() option: file_uploads, upload_max_filesize, post_max_size, max_file_uploads, max_multipart_body_parts (default max_input_vars + max_file_uploads) and upload_tmp_dir (default: the system temporary directory).

pam.toml declares applications for pam plan, pam apply and pam config:check:

pam.toml
schema_version = 1
[applications.api]
kind_code = 1
script = "index.php"
workers = 4
Key Default Allowed
schema_version required 1
kind_code required 1 PAM runtime, 2 Laravel (PAM Octane)
script index.php Path under cwd; not for kind_code = 2
cwd . Directory under the pam.toml directory
workers 1 1 to 256
arguments [] Strings without control characters
autostart true —
env_file — Private (0600) file
php_extensions [] Up to 64 names
php_extension_profile — kind_code (1 no-dev, 2 with dev), manifest_sha256, lock_sha256, lock_content_hash, extensions
shutdown_timeout_millis 20000 100 to 300000
health_check_url — http:// loopback IP and port
health_check_interval_millis 5000 250 to 3600000
health_check_timeout_millis 1000 50 to 5000, below the interval
health_check_start_period_millis 0 Up to 3600000
health_check_failure_threshold 3 1 to 100
auto_restart true Must be true with a health check
restart_delay_millis 250 10 to 60000
restart_backoff_max_millis 15000 Delay to 300000
max_unstable_restarts 10 1 to 100
min_uptime_millis 30000 1000 to 3600000
memory_warning_bytes — Positive, not above memory_max_bytes
task_warning_count — Positive, not above task_max_count
memory_max_bytes — Positive (requires systemd-run)
task_max_count — Positive (requires systemd-run)

Unknown keys are rejected. See Declarative Deploys.

The pam launcher sets PHPRC to the installation’s etc/php.ini and PHP_INI_SCAN_DIR to its etc/conf.d, plus PAM_PHP_INI_SCAN_DIR when you set it. Override single directives with -d:

Terminal window
pam -d memory_limit=512M index.php
PAM_PHP_INI_SCAN_DIR=/etc/acme/php pam start index.php

In server mode, unless exposeErrors is set, PAM forces display_errors=0 and log_errors=1. memory_limit matters more than in PHP-FPM: every request of a worker shares it. See Compatibility.