Package Commands
Applications usually need a few commands of their own: reconcile invoices, warm a cache, import a file. Packages often want to ship commands too. Instead of asking you to install another global tool, PAM lets both register commands that you run as pam <name>, executed by the same embedded PHP as your application.
PAM validates every registration before it runs anything: command names are checked, script paths are resolved and must stay inside their owner, and built-in or duplicate commands cannot be shadowed.
Listing Commands
Section titled “Listing Commands”pam commandsapp:warm Application commandbilling:reconcile Reconcile pending invoicespam commands must run inside a PAM project, that is, a directory with a pam.json manifest. When nothing is registered it prints No application or package commands are registered.
For tools and editor integrations, use the machine-readable forms instead of parsing terminal output:
pam commands --jsonpam commands --names{ "commands": [ { "description": "Application command", "name": "app:warm" }, { "description": "Reconcile pending invoices", "name": "billing:reconcile" } ], "schema": 1}--names prints one name per line; it is the list used by the generated Bash, Zsh, Fish and PowerShell completions.
Application Commands
Section titled “Application Commands”Register commands in the commands object of your project’s pam.json. Script paths are relative to the project root:
{ "$schema": "https://push-in.github.io/pam-docs/schemas/pam.schema.json", "schema": 1, "type": 1, "name": "billing-api", "commands": { "billing:reconcile": { "script": "bin/reconcile.php", "description": "Reconcile pending invoices" }, "app:warm": "bin/warm.php" }}The short form, "app:warm": "bin/warm.php", is enough when you do not need a description. The script is ordinary PHP: arguments arrive in $argv, and your Composer autoloader is already loaded.
<?php
declare(strict_types=1);
$options = getopt('', ['since:']);$since = $options['since'] ?? 'today';
echo "Reconciling invoices since {$since}" . PHP_EOL;
exit(0);pam billing:reconcile --since=yesterdayReconciling invoices since yesterdayCommand Options
Section titled “Command Options”An object definition accepts these keys:
| Key | Description |
|---|---|
script |
A PHP script, run by PAM’s embedded PHP |
bin |
A native executable, run directly |
description |
Text shown by pam commands (at most 240 characters); defaults to “Application command” |
arguments |
Up to 32 strings inserted before the user’s arguments |
environment |
Up to 32 environment variables (uppercase names) set for the command |
A definition must contain exactly one of script or bin.
{ "commands": { "billing:reconcile": { "script": "bin/reconcile.php", "description": "Reconcile pending invoices", "arguments": ["--dry-run"], "environment": { "BILLING_MODE": "batch" } } }}With this definition, pam billing:reconcile --since=yesterday runs the script with --dry-run --since=yesterday and BILLING_MODE=batch in its environment.
Package Commands
Section titled “Package Commands”A Composer package registers commands under extra.pam.commands in its own composer.json. Paths are relative to the installed package:
{ "name": "acme/pam-inspector", "type": "library", "extra": { "pam": { "commands": { "inspector:snapshot": { "script": "bin/snapshot.php", "description": "Capture an application snapshot" } } } }}When an application installs the package, the command appears automatically:
pam composer require acme/pam-inspectorpam commandsinspector:snapshot Capture an application snapshotPAM reads Composer’s vendor/composer/installed.json, uses each package’s canonical install-path, and honors a custom config.vendor-dir. Packages installed through Composer path repositories (symlinks to a checkout elsewhere) work too; their commands must stay inside the resolved package directory.
Native Executables
Section titled “Native Executables”Use bin when your package ships a compiled CLI. arguments lets several commands share one executable:
{ "extra": { "pam": { "commands": { "inspector:watch": { "bin": "bin/pam-inspector", "arguments": ["watch"], "description": "Watch application diagnostics" } } } }}A bin command runs with the project root as its working directory and receives:
- every argument the user typed, after your
argumentsprefix; PAM_BINARY: the absolute path of thepamexecutable, so your tool can call back into PAM;PAM_PACKAGE_COMMAND=1.
PAM removes its private library paths (LD_LIBRARY_PATH, DYLD_LIBRARY_PATH) and its php.ini settings (PHPRC, PHP_INI_SCAN_DIR) from the environment, so tools your executable starts (git, curl, a system php) use the host’s own setup. script commands also receive PAM_BINARY.
Naming Rules
Section titled “Naming Rules”- Names use lowercase ASCII letters, digits,
:,-and_, start with a letter or digit, and are at most 96 bytes long. - Use a namespace prefix such as
billing:orinspector:to avoid collisions. - A registration may not reuse a built-in command name. A few contextual built-ins, such as
dev,build,test,doctor,format,lint,package,releaseand themake:*generators, can be provided by installed product packages; runtime commands such asstart,composer,execandself-updatecan never be replaced. - Two registrations with the same name are an error.
When a rule is broken, command discovery fails with an error that names the registration:
× ERROR [PAM-E005] PAM command registration start shadows a built-in command× ERROR [PAM-E005] invalid PAM command name "Bad Name"Security Boundaries
Section titled “Security Boundaries”- A command’s target must exist and must resolve inside its owner: the project root for application commands, the installed package for package commands.
../paths and symlinks that escape are rejected. - A package whose install path resolves to the filesystem root, your home directory, or the project itself cannot register commands.
- A project with its own
composer.jsonnever inherits commands from the vendor directory of a parent monorepo.
The project manifest follows the public pam.schema.json JSON Schema.
Next Steps
Section titled “Next Steps”- The PAM CLI: built-in commands and the project console
- CLI Reference: every built-in command and flag
- Composer Integration: running Composer through PAM