Configuration
A PAM application is configured in a few well-defined places, each with one job:
| Where | What it configures |
|---|---|
| Environment variables | Values that change between machines: ports, credentials, PAM_ENV, proxies. |
listen() options |
The HTTP listener of one worker: limits, timeouts, TLS, CORS, metrics, caching. |
pam.json |
What kind of project this is, plus defaults for remote deploys and project commands. |
pam.toml |
The applications a host should run, for pam plan and pam apply. |
php.ini |
PHP itself: memory, OPcache, error handling. |
| Extension profile | Which dynamic PHP extensions workers load. |
This page explains each one with a working example. For the exhaustive lists, see the Configuration Reference and Environment Variables.
Environment Variables
Section titled “Environment Variables”PAM passes the process environment to PHP unchanged, so getenv() works as usual. The project templates read their port this way:
$app->listen((int) (getenv('PAM_PORT') ?: 3000));PAM_PORT=8080 pam dev index.phpPAM_PORT and PAM_HOST are conventions of the templates, not settings the runtime reads by itself. The host defaults to 127.0.0.1; containers set PAM_HOST=0.0.0.0 and pass it as the second argument of listen().
The .env File
Section titled “The .env File”The runtime does not load a .env file on its own. How it gets into the environment depends on how you run the application:
- Development.
pam devrestarts the runtime when.envchanges. Thewebtemplate’sbootstrap/app.phpreads.envand callsputenv()for every variable that is not already set, so real environment variables always win. Therawandapitemplates only ship an.env.example; export the variables in your shell or add the same loader. - Process manager.
pam up --env-file .env.productionandenv_fileinpam.tomlinject a file into the managed application. The file must belong to the current user and have mode0600or stricter; PAM refuses anything looser. - Remote deploys.
pam deploy:remotekeepsshared/.envon the server, links it into every release and passes it with--env-file.
chmod 600 .env.productionpam up index.php --name api --env-file .env.productionTyped Configuration With Nimbus
Section titled “Typed Configuration With Nimbus”Reading raw strings with getenv() everywhere makes mistakes easy to miss. Nimbus validates the environment once, at boot, and fails before the listener starts when something is missing or malformed:
<?php
declare(strict_types=1);
use Nimbus\Config\ConfigDefinition;use Nimbus\Config\Configuration;use Nimbus\Config\ConfigType;
$config = Configuration::fromEnvironment([ new ConfigDefinition('app.port', 'PAM_PORT', ConfigType::Integer, required: false, default: 3000), new ConfigDefinition('app.host', 'PAM_HOST', required: false, default: '127.0.0.1'), new ConfigDefinition('auth.secret', 'AUTH_SECRET', sensitive: true),]);
/** @var \Nimbus\App $app */$app = require __DIR__ . '/bootstrap/app.php';$app->listen($config->integer('app.port'), $config->string('app.host'));Types are ConfigType::String, Integer, Boolean and Float. Definitions are required unless you pass required: false. When AUTH_SECRET is missing, boot stops with:
Nimbus\Config\ConfigurationException: Application configuration is invalid: AUTH_SECRET is requiredUse $config->redacted() when you log configuration: values marked sensitive come back as [REDACTED].
Variables the Runtime Reads
Section titled “Variables the Runtime Reads”A few variables change PAM’s own behavior. The most common ones:
| Variable | Effect |
|---|---|
PAM_TRUSTED_PROXIES |
Comma-separated proxy addresses or CIDR ranges added to trustedProxies. |
PAM_METRICS_TOKEN |
Require Authorization: Bearer <token> on the worker’s /metrics path. |
PAM_METRICS_PUBLIC |
1 opens /metrics to every peer instead of loopback only. |
PAM_WEBSOCKET_ORIGINS |
Comma-separated origins allowed to open WebSockets. |
PAM_MAX_INFLIGHT_BODY_BYTES |
Per-worker budget for request bodies held in memory. |
PAM_ADMIN_TOKEN / PAM_ADMIN_TOKEN_FILE |
Bearer token for a non-loopback pam start --admin-address. |
NO_COLOR=1 or PAM_COLOR=never |
Disable colored CLI output. |
The Environment Variables reference lists every variable, including installer and process-manager settings.
Listener Options
Section titled “Listener Options”The third argument of listen() configures the HTTP listener of each worker. It works the same for the raw runtime and for Nimbus:
<?php
declare(strict_types=1);
use Pam\Http\Request;use Pam\Http\Response;use Pam\Http\Server;
Server::create(static function (Request $request, Response $response): Response { return $response->json(['path' => $request->path]);})->listen( (int) (getenv('PAM_PORT') ?: 3000), getenv('PAM_HOST') ?: '127.0.0.1', [ 'maxBodyBytes' => 1024 * 1024, 'requestTimeoutMs' => 10_000, 'trustedProxies' => ['10.0.0.0/8'], 'accessLog' => true, ],);Frequently used options and their defaults:
| Option | Default | Purpose |
|---|---|---|
maxBodyBytes |
2 MiB | Largest accepted request body. |
maxHeaderBytes / maxHeaders |
32 KiB / 100 | Header limits. |
requestTimeoutMs |
30000 |
Deadline for one request; past it PAM answers 504 and recycles the worker. |
headerReadTimeoutMs / bodyReadTimeoutMs |
10000 / 30000 |
Slow-client protection. |
maxConcurrentRequests |
4096 |
Requests a worker interleaves as Fibers. Laravel forces 1. |
maxConnections |
open-file limit minus 256 | Connections one worker accepts before it pauses accepting. |
rateLimitPerSecond |
0 (off) |
Per-client rate limit. |
corsOrigins |
none | Allowed CORS origins. |
trustedProxies |
none | Proxies whose X-Forwarded-For is honored. |
tlsCert / tlsKey |
none | Serve HTTPS directly. HTTP/3 (http3, on by default) needs TLS; HTTP/2 also works over cleartext (h2c). |
exposeErrors |
false |
Show PHP errors in responses. Keep it off in production. |
accessLog |
false |
One JSON log line per request. |
metricsPath |
/metrics |
Prometheus endpoint of the worker (loopback only by default). |
The Configuration Reference documents every option, including WebSockets, HTTP/2 windows, response caching and garbage collection.
The pam.json Manifest
Section titled “The pam.json Manifest”Every project has a pam.json at its root. PAM finds the nearest one from the current directory, which is how pam dev, pam test and pam build know which project they are in.
{ "$schema": "https://push-in.github.io/pam-docs/schemas/pam.schema.json", "name": "hello-api", "schema": 1, "type": 1, "version": "0.1.0"}| Key | Meaning |
|---|---|
schema |
Manifest format version. Always 1. |
type |
Project kind: 1 API (also used by the web template), 2 Native, 3 Laravel, 4 Desktop, 5 Raw runtime, 6 Product workspace. |
name |
Project name, 1 to 80 characters. Also the default process name for remote deploys. |
version |
Your application’s SemVer version. |
native |
PAM Native only: applicationId, starter and platforms. |
workspace |
Product workspaces only. |
deploy |
Defaults for pam deploy:remote: host, path, name, workers, healthCheckUrl, keep, pam. Command-line options win. |
commands |
Project commands exposed as pam <name>. See Package Commands. |
Unknown keys are rejected by the schema. Point your editor at the $schema URL to get completion and validation.
{ "$schema": "https://push-in.github.io/pam-docs/schemas/pam.schema.json", "name": "hello-api", "schema": 1, "type": 1, "version": "0.1.0", "deploy": { "workers": 4, "healthCheckUrl": "http://127.0.0.1:3000/api/ping", "keep": 5 }}The pam.toml File
Section titled “The pam.toml File”pam.toml describes the applications that should run on a host, in the spirit of a Terraform plan: you declare the desired state, pam plan previews the changes without touching anything, and pam apply makes them.
schema_version = 1
[applications.api]kind_code = 1script = "index.php"workers = 4env_file = ".env.production"health_check_url = "http://127.0.0.1:3000/api/ping"pam config:check pam.tomlpam planpam applypam.toml is valid (1 applications)Planned 1 applications from pam.tomlapi action 1kind_code = 1 is a raw PAM application; 2 is Laravel Octane and requires artisan in its working directory. Worker counts are bounded to 1–256, unknown fields fail validation, and paths must stay beneath the directory that holds pam.toml. Declarative Deploys covers every field and the plan output.
PHP Configuration
Section titled “PHP Configuration”Each PAM release ships its own php.ini and a conf.d/ directory with one file per extension. pam doctor prints their location:
◆ [info] Embed php.ini: /home/alice/.local/share/pam/v2.2.27-linux-x86_64/etc/php.ini◆ [info] Embed scanned INI files: 38Do not edit those files: an update replaces them. Override settings instead, with the same flags PHP’s CLI uses:
pam -d memory_limit=256M index.php # set one directivepam -c config/php.ini index.php # use another php.inipam -n script.php # ignore php.ini and conf.dTo add your own .ini files on top of the release’s conf.d, point PAM_PHP_INI_SCAN_DIR at a directory. The pam launcher appends it to the scan path:
memory_limit = 256MPAM_PHP_INI_SCAN_DIR="$PWD/config/php.d" pam start index.php --workers 4PAM also applies server-friendly defaults on its own:
- In server mode,
display_errorsis off,log_errorsis on andexpose_phpis off unless you setexposeErrors. pam startenables OPcache for the CLI withopcache.validate_timestamps=0and the tracing JIT (opcache.jit=tracing,opcache.jit_buffer_size=128M), unless you set those directives yourself. Code changes therefore need a reload, whichpam devandSIGHUPhandle.
PHP Extensions
Section titled “PHP Extensions”By default PAM runs in compatible mode: workers load every extension the release ships (bcmath, curl, gd, intl, mbstring, pdo_mysql, pdo_pgsql, pdo_sqlite, sockets, zip and more). That is convenient, but production workers are leaner and expose less when they load only what the application needs.
pam extensions derives that list from your locked Composer requirements, including the ext-* requirements of every transitive package. It never changes anything; it explains the result and prints arguments for you to review:
pam extensions --no-devComposer PHP extension profile (schema 1)Project: /home/alice/hello-apiRequirements: 2Built into PHP:Provided by packages:Dynamic selection: pdo, tokenizerReview and append these explicit arguments to pam start or pam up: --php-extension pdo --php-extension tokenizerCompatible mode remains the default until you apply these arguments.Here pdo comes from pushinbr/arcano and tokenizer from spiral/tokenizer; --json shows that origin for every requirement. Drop --no-dev to include development dependencies.
Apply the profile with repeatable --php-extension options on pam start or pam up. Workers then skip the global conf.d scan and load only the listed modules; the main php.ini stays active:
pam start index.php --workers 8 \ --php-extension pdo --php-extension pdo_pgsql --php-extension tokenizerFor declarative deploys, --toml prints a hash-pinned block you can paste into pam.toml (replace APP with your application name):
pam extensions --no-dev --toml[applications.APP.php_extension_profile]kind_code = 1manifest_sha256 = "ef3cf91668f0ead61ff93a7611b084b26bb1143af4f453ff9c1b3b24c3579d3d"lock_sha256 = "f7b200911f2dc81c1718228f3a5b2c276f9e459a2e99b7126c6b3379e48fc367"lock_content_hash = "6e1116331e43de4f65f6e46c657bb4d3"extensions = ["pdo", "tokenizer"]The profile is bound to the exact composer.json and composer.lock. If the lock no longer matches the manifest, PAM refuses and asks you to run pam composer update --lock first.
Next Steps
Section titled “Next Steps”- Directory Structure: where each of these files lives.
- Configuration Reference and Environment Variables.
- Production: recommended settings for real traffic.