Composer Integration
PAM works with plain Composer projects. There is no PAM-specific lockfile, no package wrapper and no separate PHP install: pam composer runs the real Composer inside PAM’s embedded PHP, so the PHP version and extensions Composer checks against are exactly the ones your application will run on.
This page covers running Composer, how PAM finds your autoloader, what changes when the autoloader lives in a long-running process, and how to turn your composer.lock into an explicit list of PHP extensions for production.
Running Composer
Section titled “Running Composer”Prefix any Composer command with pam:
pam composer installpam composer require pushinbr/nimbuspam composer require --dev pushinbr/pam-http-testingpam composer updatepam composer audit --lockedpam composer --versionComposer version 2.11.2 2026-11-10 10:09:37PHP version 8.5.13 (~/.local/share/pam/v2.2.27-linux-x86_64/bin/pam)The PHP version Composer reports is PAM’s embedded PHP. You do not need a php binary on your PATH, and you should not use one: a system PHP with a different version or extension set would resolve different packages than the runtime that executes them.
Where Composer Comes From
Section titled “Where Composer Comes From”The first time you run pam composer, PAM downloads the official installer from getcomposer.org, verifies it against Composer’s published SHA-384 signature, and caches composer.phar in $XDG_CACHE_HOME/pam (or ~/.cache/pam when XDG_CACHE_HOME is unset). Later runs reuse the cached PHAR.
To use a specific, trusted PHAR instead, point PAM_COMPOSER at it:
PAM_COMPOSER=/opt/tools/composer.phar pam composer installComposer Scripts
Section titled “Composer Scripts”Composer scripts run inside PAM as well. Projects created with pam init define test, migrate and similar scripts that call PAM themselves, so you run them the same way:
pam composer testHow PAM Finds Your Autoloader
Section titled “How PAM Finds Your Autoloader”When PAM runs a script, it walks up from the script’s directory to the nearest composer.json whose vendor directory contains autoload.php, honors a custom config.vendor-dir (relative or absolute), and loads that autoloader before your script. You never need to require 'vendor/autoload.php' yourself, although doing so is harmless.
{ "config": { "vendor-dir": "lib/vendor" }}pam doctor confirms what was found, and proves that Composer’s generated platform check passes inside the embedded runtime:
◆ [info] Composer root: /srv/acme/api◆ [info] Composer vendor directory: /srv/acme/api/vendor● [ok] Composer autoload: /srv/acme/api/vendor/autoload.php● [ok] Composer autoloader and generated platform check loaded inside EmbedIf a system PHP CLI is present, pam doctor also compares it with the embedded runtime (version, ABI, thread safety, integer size, extensions) and reports differences. The system CLI is only diagnostic context; PAM never depends on it.
Autoloading in a Persistent Process
Section titled “Autoloading in a Persistent Process”In PHP-FPM, Composer’s autoloader and every class it loads are rebuilt on each request. In PAM they are loaded once per worker and stay in memory, together with OPcache’s compiled code. Two practical consequences:
New dependencies need a restart. After pam composer require or pam composer update, running workers still hold the old classes. pam dev restarts automatically because it watches Composer files; in production, perform a zero-downtime reload after deploying new vendor code.
Optimize the autoloader for production. The classmap is built once per worker, so an authoritative classmap costs nothing per request and avoids filesystem lookups:
pam composer install --no-dev --optimize-autoloader --classmap-authoritativeExtension Profiles
Section titled “Extension Profiles”By default every bundled PHP extension is loaded. For production you can load only what your dependencies need. pam extensions reads your locked Composer requirements (ext-* entries in composer.json and composer.lock), subtracts what is compiled into PHP or provided by packages (polyfills), and prints the result:
pam extensions --no-devComposer PHP extension profile (schema 1)Project: /srv/acme/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.The command only explains; it never changes how your application runs. Apply the result yourself:
pam start index.php --workers 8 --php-extension pdo --php-extension tokenizer| Option | Meaning |
|---|---|
--no-dev |
Ignore root and locked development requirements |
--json |
Emit a versioned, explainable report, including which package required each extension |
--toml |
Emit a pinned profile ready to paste into pam.toml |
With --toml, the profile is pinned to the exact composer.json and composer.lock it was derived from, so a declarative deploy can refuse a profile that no longer matches the lock:
[applications.APP.php_extension_profile]kind_code = 1manifest_sha256 = "ef3cf91668f0ead61ff93a7611b084b26bb1143af4f453ff9c1b3b24c3579d3d"lock_sha256 = "f7b200911f2dc81c1718228f3a5b2c276f9e459a2e99b7126c6b3379e48fc367"lock_content_hash = "6e1116331e43de4f65f6e46c657bb4d3"extensions = ["pdo", "tokenizer"]Replace APP with your application’s name. See Declarative Deploys.
pam extensions requires a fresh composer.lock: if composer.json changed since the lock was written, run pam composer update --lock first. The command exits with status 1 when a required extension is missing from the runtime.
Package Compatibility
Section titled “Package Compatibility”The PAM repository keeps a locked smoke application that exercises popular packages inside the embedded runtime on every change:
| Category | Exercised in the smoke suite |
|---|---|
| Pure PHP and PSR-4 packages | Loaded by the normal Composer autoloader |
| PSR-7, PSR-15, PSR-17 | Through pushinbr/pam-http-psr |
| PSR-3 | psr/log, Monolog |
| HTTP clients | Guzzle |
| Event loops | Amp, Revolt, ReactPHP |
| Telemetry | OpenTelemetry API, SDK and OTLP exporter |
| Illuminate 13 | Container, Events, Filesystem, Pipeline |
| Symfony 8 | HttpKernel |
| Slim 4 | Request handling and routing |
| Testing | PHPUnit and Pest through pam test |
PHP extensions work when they can be loaded by PAM’s Embed SAPI. A green smoke suite lowers known risk; it cannot prove that every future package version is free of long-lived state, so keep worker recycling as a safety net and add the dependencies that matter to you to your own tests.
Next Steps
Section titled “Next Steps”- PHP Runtime Manager: the embedded PHP and its settings
- Package Commands: ship
pamcommands from a Composer package - Compatibility: the full compatibility contract