Configuration
A Laravel application on PAM is configured in three places:
.envandconfig/*.php: your normal Laravel configuration. Nothing changes here.pam.php: the HTTP listener: port, timeouts, body and response limits, proxies, TLS, and the edge cache.config/pam.php: only when you installpushinbr/pam-laravel. It controls the state guard, health routes, telemetry, deployment, and process supervision.
Command-line flags on pam start (workers, recycling, admin listener) are
covered in Performance Tuning and the
command reference.
The pam.php Entrypoint
Section titled “The pam.php Entrypoint”pam.php boots Laravel once and starts the listener:
<?php
declare(strict_types=1);
use Pam\Laravel\Application;
$app = Application::boot(__DIR__);$app->listen( port: (int) (getenv('PAM_PORT') ?: 3000), host: (string) (getenv('PAM_HOST') ?: '127.0.0.1'), options: [ 'maxConcurrentRequests' => 1, 'responseStreamQueueCapacity' => 16, 'maxResponseBytes' => 256 * 1024 * 1024, 'maxResponseChunkBytes' => 1024 * 1024, 'exposeErrors' => filter_var(getenv('APP_DEBUG') ?: 'false', FILTER_VALIDATE_BOOLEAN), ],);Application::boot() requires bootstrap/app.php, which must return an
Illuminate\Foundation\Application, bootstraps the HTTP kernel, and resolves
the long-lived managers (auth, cache, db, filesystem, mail.manager,
queue, session) so they are shared by every request.
Listener Options
Section titled “Listener Options”The options array accepts PAM’s HTTP server options. The ones you are most
likely to change:
| Option | Default | Description |
|---|---|---|
maxConcurrentRequests |
1 (forced) |
Laravel requests per worker. Any other value aborts startup. |
requestTimeoutMs |
30000 |
Hard request deadline. A request past it gets 504 and the worker is replaced. |
maxBodyBytes |
2 MiB | Largest request body held in memory (JSON, form, raw). Multipart uploads stream to temporary files. |
maxHeaderBytes / maxHeaders |
32 KiB / 100 |
Request header limits |
maxResponseBytes |
256 MiB | Largest response, including streamed and file responses |
maxResponseChunkBytes |
1 MiB | Largest single chunk; cannot exceed maxResponseBytes |
responseStreamQueueCapacity |
16 in pam.php |
Chunks buffered before backpressure pauses the stream |
phpExecutorQueueCapacity |
1024 |
Requests that may wait for the worker’s PHP slot |
trustedProxies |
[] |
Proxy IPs or CIDR ranges allowed to set X-Forwarded-For |
tlsCert / tlsKey |
null |
PEM files; PAM then terminates TLS itself |
exposeErrors |
false |
Show error details from the transport layer |
accessLog / accessLogSampleRate |
false / 1 |
Structured JSON access log, optionally sampled |
routeMetrics |
false |
Opt-in per-route counters and histograms, bounded by routeMetricsMaxEntries (256) |
responseCachePaths |
[] |
Paths PAM may serve from its edge cache (Performance Tuning) |
Example: Behind a Load Balancer
Section titled “Example: Behind a Load Balancer”$app->listen( port: (int) (getenv('PAM_PORT') ?: 3000), host: (string) (getenv('PAM_HOST') ?: '127.0.0.1'), options: [ 'maxConcurrentRequests' => 1, 'requestTimeoutMs' => 15_000, 'maxBodyBytes' => 8 * 1024 * 1024, 'trustedProxies' => ['10.0.0.0/8'], 'responseStreamQueueCapacity' => 16, 'maxResponseBytes' => 256 * 1024 * 1024, 'maxResponseChunkBytes' => 1024 * 1024, ],);You can also add trusted proxies with the comma-separated PAM_TRUSTED_PROXIES
environment variable; it is merged with the option.
Environment Variables
Section titled “Environment Variables”These variables are read by the runtime or by the generated pam.php:
| Variable | Used by | Description |
|---|---|---|
PAM_PORT |
pam.php |
Listening port (default 3000) |
PAM_HOST |
pam.php |
Listening address (default 127.0.0.1) |
APP_DEBUG |
pam.php |
Also drives exposeErrors in the generated file |
PAM_LARAVEL_STORAGE_PATH |
runtime | Writable storage directory for read-only releases |
PAM_TRUSTED_PROXIES |
runtime | Extra trusted proxies, comma-separated |
PAM_ADMIN_TOKEN / PAM_ADMIN_TOKEN_FILE |
pam start |
Bearer token required when the admin listener is not on loopback |
PAM_PREFORK |
pam start |
0 starts each worker with exec instead of forking from a zygote (Linux) |
PAM_WORKER_ID |
set by PAM | The worker’s ID, readable from your code |
Read-Only Application Directories
Section titled “Read-Only Application Directories”In a hardened deployment the release directory is read-only. Point Laravel’s storage at a writable directory:
PAM_LARAVEL_STORAGE_PATH=/var/lib/pam pam start pam.php --workers 4Before the kernel boots, PAM checks the directory is writable, calls
useStoragePath(), and creates app/private, app/public,
framework/cache/data, framework/sessions, framework/testing,
framework/views, and logs when they are missing. Build
bootstrap/cache (config, routes, events, views) during the release, before
the directory becomes read-only.
The config/pam.php File
Section titled “The config/pam.php File”Installing pushinbr/pam-laravel merges these defaults; publish them with
pam artisan pam:install or pam artisan vendor:publish --tag=pam-config.
Every key can be set from .env.
Health and Metrics Routes
Section titled “Health and Metrics Routes”| Key | Env | Default |
|---|---|---|
health.enabled |
PAM_LARAVEL_HEALTH_ENABLED |
true |
health.path |
PAM_LARAVEL_HEALTH_PATH |
/__pam/health |
health.metrics_path |
PAM_LARAVEL_METRICS_PATH |
/__pam/metrics |
health.token |
PAM_LARAVEL_OBSERVABILITY_TOKEN |
none: metrics are public |
Request Observability
Section titled “Request Observability”| Key | Env | Default |
|---|---|---|
observability.enabled |
PAM_LARAVEL_OBSERVABILITY |
true |
observability.slow_request_ms |
PAM_LARAVEL_SLOW_REQUEST_MS |
500 |
observability.slow_query_ms |
PAM_LARAVEL_SLOW_QUERY_MS |
100 |
observability.route_limit |
PAM_LARAVEL_ROUTE_LIMIT |
256 |
observability.query_limit |
PAM_LARAVEL_QUERY_LIMIT |
128 |
observability.n_plus_one_threshold |
PAM_LARAVEL_N_PLUS_ONE_THRESHOLD |
8 |
observability.response_headers |
PAM_LARAVEL_TIMING_HEADERS |
false (adds Server-Timing) |
OpenTelemetry
Section titled “OpenTelemetry”| Key | Env | Default |
|---|---|---|
telemetry.enabled |
PAM_OTLP_ENABLED |
false |
telemetry.service_name |
OTEL_SERVICE_NAME |
APP_NAME |
telemetry.service_version |
OTEL_SERVICE_VERSION |
APP_VERSION or unknown |
telemetry.buffer_limit |
PAM_OTLP_BUFFER_LIMIT |
512 spans |
telemetry.fail_hard |
PAM_OTLP_FAIL_HARD |
false |
telemetry.otlp.endpoint |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, OTEL_EXPORTER_OTLP_ENDPOINT |
http://127.0.0.1:4318 |
telemetry.otlp.header_string |
OTEL_EXPORTER_OTLP_TRACES_HEADERS, OTEL_EXPORTER_OTLP_HEADERS |
empty |
telemetry.otlp.timeout_ms |
OTEL_EXPORTER_OTLP_TRACES_TIMEOUT, OTEL_EXPORTER_OTLP_TIMEOUT |
500 |
telemetry.otlp.compression |
OTEL_EXPORTER_OTLP_TRACES_COMPRESSION, OTEL_EXPORTER_OTLP_COMPRESSION |
none (gzip supported) |
State Guard
Section titled “State Guard”| Key | Env | Default |
|---|---|---|
state_guard.enabled |
PAM_LARAVEL_STATE_GUARD |
true |
state_guard.strict |
PAM_LARAVEL_STATE_GUARD_STRICT |
false; true turns a leak into a 500 |
Production Policy
Section titled “Production Policy”Used by pam:check-production:
| Key | Env | Default |
|---|---|---|
production.require_config_cache |
PAM_REQUIRE_CONFIG_CACHE |
true |
production.require_route_cache |
PAM_REQUIRE_ROUTE_CACHE |
false |
production.distributed_cache |
PAM_REQUIRE_DISTRIBUTED_CACHE |
true (rejects array, file, cookie) |
production.distributed_session |
PAM_REQUIRE_DISTRIBUTED_SESSION |
true (rejects array, file, cookie) |
production.queue_sync_allowed |
PAM_QUEUE_SYNC_ALLOWED |
false |
production.required_extensions |
none | ctype, filter, json, mbstring, openssl, pcntl, pdo, posix, tokenizer |
Deployment, Processes, and Autoscaling
Section titled “Deployment, Processes, and Autoscaling”| Key | Env | Default |
|---|---|---|
deploy.root |
PAM_DEPLOY_ROOT |
base_path('releases') |
deploy.current |
PAM_DEPLOY_CURRENT |
base_path('current') |
deploy.keep_releases |
PAM_DEPLOY_KEEP_RELEASES |
5 |
deploy.readiness_url |
PAM_DEPLOY_READINESS_URL |
http://127.0.0.1:3010/ready |
deploy.readiness_timeout_seconds |
PAM_DEPLOY_READINESS_TIMEOUT |
30 |
deploy.migrate |
PAM_DEPLOY_MIGRATE |
true |
deploy.binary |
PAM_DEPLOY_BINARY |
pam |
supervisor.manifest |
PAM_PROCESS_MANIFEST |
base_path('pam.processes.json') |
supervisor.state_path |
PAM_PROCESS_STATE |
storage_path('pam/processes') |
supervisor.log_path |
PAM_PROCESS_LOGS |
storage_path('logs/pam') |
supervisor.stop_timeout_seconds |
PAM_PROCESS_STOP_TIMEOUT |
10 |
autoscaling.min_instances |
PAM_AUTOSCALE_MIN |
1 |
autoscaling.max_instances |
PAM_AUTOSCALE_MAX |
16 |
autoscaling.target_cpu_percent |
PAM_AUTOSCALE_TARGET_CPU |
65 |
autoscaling.target_p95_ms |
PAM_AUTOSCALE_TARGET_P95_MS |
250 |
autoscaling.cooldown_seconds |
PAM_AUTOSCALE_COOLDOWN |
60 |
autoscaling.metrics_url |
PAM_AUTOSCALE_METRICS_URL |
none |
autoscaling.metrics_token |
PAM_AUTOSCALE_METRICS_TOKEN |
none |
Remote Targets, Nightwatch, and MCP
Section titled “Remote Targets, Nightwatch, and MCP”| Key | Env | Default |
|---|---|---|
remote.timeout_seconds |
PAM_REMOTE_TIMEOUT |
15 |
remote.allow_insecure_http |
PAM_REMOTE_ALLOW_HTTP |
false |
remote.cloud.url / project / token |
PAM_CLOUD_URL, PAM_CLOUD_PROJECT, PAM_CLOUD_TOKEN |
none |
remote.targets.production.provider |
PAM_REMOTE_PRODUCTION_PROVIDER |
1 (PAM Cloud; 2 = Forge) |
remote.targets.production.webhook |
PAM_FORGE_PRODUCTION_WEBHOOK |
none |
remote.targets.staging.provider |
PAM_REMOTE_STAGING_PROVIDER |
1 |
remote.targets.staging.webhook |
PAM_FORGE_STAGING_WEBHOOK |
none |
nightwatch.token |
NIGHTWATCH_TOKEN |
none |
mcp.allow_mutations |
PAM_MCP_ALLOW_MUTATIONS |
false |
mcp.confirmation_token |
PAM_MCP_CONFIRMATION_TOKEN |
none |
compatibility_registry |
PAM_COMPATIBILITY_REGISTRY |
the registry URL in the PAM repository |