Declarative Deploys
Instead of remembering a long pam up command for every application on a server, you can describe them once in a pam.toml file and let PAM reconcile the machine to match it. pam plan shows what would change without touching anything; pam apply makes it so. The same file is safe to keep in version control: it holds names, paths and policies, while secrets stay in private environment files.
This page also covers the commands that move an application from one release to the next: pam deploy and pam rollback for local release directories, pam deploy:remote to ship to a server over SSH, and the traffic:* commands for weighted canary releases.
Your First pam.toml
Section titled “Your First pam.toml”Create pam.toml next to your application:
schema_version = 1
[applications.api]kind_code = 1script = "index.php"cwd = "."workers = 4env_file = ".env.production"shutdown_timeout_millis = 20000health_check_url = "http://127.0.0.1:3000/api/ping"health_check_start_period_millis = 10000memory_warning_bytes = 536870912
[applications.reports]kind_code = 1script = "index.php"workers = 1autostart = falseEach [applications.NAME] table becomes one managed application with that name. kind_code = 1 is a PAM runtime application (a PHP entry point started with pam start); kind_code = 2 is a Laravel application started through PAM Octane (it uses the directory’s artisan file and cannot set script).
The environment file must be private, exactly as with pam up --env-file:
chmod 600 .env.productionValidating, Planning and Applying
Section titled “Validating, Planning and Applying”pam config:checkpam.toml is valid (2 applications)config:check parses the file, checks every value against its allowed range, resolves every script and environment file, and verifies pinned extension profiles. It never starts anything.
pam planPlanned 2 applications from pam.tomlapi action 1reports action 5plan computes the action for each application without changing the machine. When you are happy with it:
pam applyApplied 2 applications from pam.tomlapi action 1reports action 5All three commands read pam.toml from the current directory by default; pass another path as the first argument. --json emits a stable document for CI:
pam plan --json{"applied":false,"changeCount":2,"configurationSha256":"2a8a7157...","modeCode":1,"results":[{"actionCode":1,"name":"api","structuralIdentitySha256":"7a48ffa3..."},{"actionCode":5,"name":"reports","structuralIdentitySha256":"7a48ffa3..."}],"schemaVersion":1}modeCode is 1 for plan and 2 for apply; changeCount counts every result that is not Unchanged.
Action Codes
Section titled “Action Codes”| Code | Action | When |
|---|---|---|
1 |
Created | The application does not exist yet; apply starts it |
2 |
Unchanged | Nothing to do |
3 |
Scaled | Only workers changed; apply runs pam scale |
4 |
Restarted | The environment file, health check or extension selection changed, or the application was stopped; apply restarts it |
5 |
Disabled | autostart = false; apply stops the application if it exists |
6 |
PolicyUpdated | Recovery, shutdown or warning thresholds changed; applied without a restart |
7 |
ResourceLimitsUpdated | memory_max_bytes or task_max_count changed; apply restarts under the new limits |
8 |
Replaced | The structural identity changed (kind_code, cwd, the resolved script, or arguments); apply replaces the application |
For example, raising workers from 2 to 3 plans action 3; changing health_check_interval_millis plans action 4.
Configuration Keys
Section titled “Configuration Keys”pam.toml rejects unknown keys. The top level has schema_version (must be 1) and one to 1024 [applications.NAME] tables. Application names are 1 to 64 ASCII letters, digits, ., _ or -.
| Key | Type | Default | Notes |
|---|---|---|---|
kind_code |
integer | required | 1 PAM runtime, 2 Laravel (PAM Octane) |
script |
path | index.php |
Relative to cwd; not allowed for kind_code = 2 |
cwd |
path | . |
Relative to the directory of pam.toml; must stay inside it |
workers |
integer | 1 |
1 to 256 |
arguments |
string array | [] |
Passed to the application after -- |
autostart |
boolean | true |
false keeps the application stopped |
env_file |
path | — | Private (0600) KEY=value file |
php_extensions |
string array | [] |
Extension allowlist (up to 64); cannot be combined with a profile |
php_extension_profile |
table | — | Pinned profile from pam extensions --toml (see below) |
shutdown_timeout_millis |
integer | 20000 |
100 to 300000 |
health_check_url |
string | — | http:// with an explicit loopback IP and port |
health_check_interval_millis |
integer | 5000 |
250 to 3600000 |
health_check_timeout_millis |
integer | 1000 |
50 to 5000, below the interval |
health_check_start_period_millis |
integer | 0 |
Up to 3600000; needs a health check URL |
health_check_failure_threshold |
integer | 3 |
1 to 100 |
auto_restart |
boolean | true |
Must be true when a health check is set |
restart_delay_millis |
integer | 250 |
10 to 60000 |
restart_backoff_max_millis |
integer | 15000 |
At least the delay, at most 300000 |
max_unstable_restarts |
integer | 10 |
1 to 100 |
min_uptime_millis |
integer | 30000 |
1000 to 3600000 |
memory_warning_bytes |
integer | — | Raises a warning in pam monit |
task_warning_count |
integer | — | Raises a warning in pam monit |
memory_max_bytes |
integer | — | Hard limit through a systemd user scope |
task_max_count |
integer | — | Hard limit through a systemd user scope |
Every key mirrors a pam up option; see Process Management for what each policy does.
Pinning PHP Extensions
Section titled “Pinning PHP Extensions”pam extensions reads your locked Composer requirements and derives the exact PHP extensions the application needs. With --toml, it prints a profile you can paste into pam.toml:
pam extensions --no-dev --toml[applications.APP.php_extension_profile]kind_code = 1manifest_sha256 = "90da1da509c6e1c5a9f09c0d450339a6ea64ebd5739d13fbcc2a127a17873649"lock_sha256 = "5d27910cb49eaf0e03777f51ff9404e0aa949fc3f99ffacff91f84b81099805e"lock_content_hash = "d58bca9fd86605e6f4d5b145130151bf"extensions = ["mbstring", "pdo_pgsql"]Replace APP with the application name. kind_code = 1 excludes development requirements (--no-dev); 2 includes them. The profile pins the hashes of composer.json and composer.lock: when they change and the derived list no longer matches, config:check, plan and apply fail instead of silently loading a different set:
× ERROR [PAM-E005] application "api" PHP extension profile drifted at extensions; pinned ["mbstring"], derived ["mbstring", "pdo_pgsql"]Releasing a New Version Locally
Section titled “Releasing a New Version Locally”pam deploy points a managed application at a new release directory, waits for it to become ready, and records the change:
pam deploy api /srv/api/releases/2026-12-02pam deploy:history apipam rollback apiDeployed api -> /srv/api/releases/2026-12-02RELEASE EVENT ACTIVATED_AT_MS/srv/api/releases/2026-12-01 1 1796237109267/srv/api/releases/2026-12-02 2 1796237109548Rolled back api -> /srv/api/releases/2026-12-01Event codes are 1 baseline, 2 deploy and 3 rollback. pam rollback NAME --steps N goes back N releases; history keeps the last 50 entries.
How activation works: PAM stops the current release, starts the candidate with the same settings, and waits for readiness. If the candidate fails, the previous release is restored and the command fails with release failed readiness and previous release was restored. Because the old release stops before the new one starts, expect a short gap on that port. For a reload without any gap, update the code in place (for example, a current symlink) and run pam reload NAME, or put a traffic ingress in front.
Deploying to a Server
Section titled “Deploying to a Server”pam deploy:remote ships a Composer application to a Linux server over SSH with your system ssh and rsync, installs production dependencies there, runs bin/migrate when it exists, and activates the release through a per-application pamd:
pam deploy:remote --dry-runThe first run with --init creates the layout, writes a private shared/.env from your .env.example when the server has none, and installs a pam-NAME.service systemd user unit that brings the application back after a reboot. On the server:
ROOT/releases/<UTC timestamp>/ one directory per releaseROOT/shared/.env linked into every release and passed as --env-fileROOT/shared/storage/ linked as storage/ROOT/state/ PAM_MANAGER_STATE_DIR of the application's pamdROOT/current -> releases/<id> the active release| Option | Default | Description |
|---|---|---|
--init |
off | Create shared/.env and install pam-NAME.service |
--path DIR |
pam-apps/NAME |
Release root on the server (absolute, or relative to the remote home) |
--name NAME |
pam.json name |
Process-manager name |
--workers N |
— | Workers of the first pam up |
--health-check-url URL |
— | Readiness URL of the first pam up |
--keep N |
5 | Releases kept on the server |
--pam PATH |
pam |
The pam executable on the server |
--dry-run |
off | Print the ssh and rsync commands only |
Put the defaults in the deploy section of pam.json; command-line options win:
{ "$schema": "https://push-in.github.io/pam-docs/schemas/pam.schema.json", "schema": 1, "type": 1, "name": "acme-api", "version": "1.0.0", "deploy": { "path": "pam-apps/acme-api", "workers": 4, "healthCheckUrl": "http://127.0.0.1:3000/ready", "keep": 5 }}The server needs PAM installed. deploy:remote refuses a project without composer.json.
Canary Releases
Section titled “Canary Releases”The traffic ingress is a small Rust proxy that splits requests between a stable and a candidate address by weight, then promotes or aborts the candidate from live error rates. Weights are basis points: 10000 is 100%.
# Front the stable release (optionally terminating TLS)pam traffic:start api-edge --listen 127.0.0.1:8080 --stable 127.0.0.1:8081
# Send 5% of traffic to the candidatepam traffic:set api-edge --candidate 127.0.0.1:8082 --weight-bps 500
# Promote automatically once 1000 candidate requests have at most 0.5% errorspam traffic:evaluate api-edge --min-candidate-requests 1000 --max-candidate-error-bps 50 --json
pam traffic:status api-edgepam traffic:promote api-edge # or traffic:abortpam traffic:stop api-edgetraffic:evaluate returns a decision: 1 pending (not enough candidate requests yet), 2 promoted (the candidate becomes stable), 3 aborted (error rate over the limit), 4 aborted because the rollout deadline passed. --deadline-seconds (1 to 604800, default 300) sets that deadline on traffic:start and traffic:set. traffic:start also accepts --candidate, --weight-bps, --tls-cert and --tls-key.
Next Steps
Section titled “Next Steps”- Process Management for the commands behind every action.
- Security & Bundle Integrity to verify what you deploy.
- Configuration Reference for
pam.jsonandpam.tomlin one place.