Artisan, Queues & Scheduler
HTTP traffic is served by pam start pam.php. Everything else your
application runs (migrations, queue workers, the scheduler, Horizon,
Nightwatch, custom daemons) is an Artisan command, and PAM runs Artisan with
its embedded PHP through pam artisan.
Keep the two worlds separate: never consume a queue or run the scheduler inside an HTTP request. Each long-running role is its own process with its own restart, scaling, and memory policy.
Running Artisan
Section titled “Running Artisan”pam artisan migrate --forcepam artisan route:listpam artisan tinkerpam artisan aboutpam artisan gives Artisan a real console identity:
app()->runningInConsole()istrueandPHP_SAPIiscli, so packages register their commands and publishables;- arguments, standard input/output/error, and exit codes behave normally; and
PHP_BINARYis thepambinary. Laravel features that spawnPHP_BINARY artisan ...(the scheduler’s background tasks, Horizon’s supervisors) therefore startpam artisan ...automatically.
Queue Workers
Section titled “Queue Workers”Queue workers run exactly as in any Laravel application:
pam artisan queue:work redis --sleep=1 --tries=3 --max-time=3600A job dispatched from an HTTP request goes through the request’s sandboxed Bus dispatcher to the shared queue connection, and a worker picks it up:
public function store(StoreInvoiceRequest $request): JsonResponse{ $invoice = Invoice::create($request->validated());
SendInvoice::dispatch($invoice);
return response()->json($invoice, 201);}pam artisan queue:work --once --stop-when-empty2026-12-02 18:50:09 App\Jobs\DemoJob .......... RUNNING2026-12-02 18:50:09 App\Jobs\DemoJob .......... 3.69ms DONEqueue:work is itself a long-running PHP process, so the advice from
Request Lifecycle applies here too. PAM’s
request sandbox does not wrap queue jobs: follow Laravel’s own guidance
for --max-jobs, --max-time, --memory, timeouts, and idempotent jobs.
Task Scheduling
Section titled “Task Scheduling”Run the scheduler as one long-lived process:
pam artisan schedule:workor from cron, once a minute:
* * * * * cd /srv/app/current && pam artisan schedule:run >> /dev/null 2>&1Scheduled closures and commands run as usual:
use Illuminate\Support\Facades\Schedule;
Schedule::command('reports:daily')->dailyAt('02:00')->onOneServer();Schedule::job(new PruneExports)->hourly();Run exactly one scheduler per environment, or use onOneServer() with a
shared cache store.
Horizon, Reverb, and Nightwatch
Section titled “Horizon, Reverb, and Nightwatch”These packages ship their own long-running Artisan commands. Run each as a separate process:
| Package | Command | Notes |
|---|---|---|
| Laravel Horizon | pam artisan horizon |
Horizon spawns its supervisors with PHP_BINARY, which is pam. Horizon is exercised on Laravel 12 in PAM’s compatibility suite. |
| Laravel Reverb | pam artisan reverb:start |
PAM’s suite covers Reverb provider discovery; validate the WebSocket server under your own load. |
| Laravel Nightwatch | pam artisan nightwatch:agent |
pam artisan pam:nightwatch --install-process adds it to the manifest. |
PAM also has its own WebSocket transport. Pass --socket to pam init to
serve WebSockets on the same listener as HTTP.
The Process Manifest
Section titled “The Process Manifest”pushinbr/pam-laravel can start, stop, and scale your long-running roles from
one JSON file. pam artisan pam:install publishes this default:
{ "processes": { "http": { "command": ["pam", "start", "pam.php", "--workers", "2", "--admin-address", "127.0.0.1:3011"], "instances": 1 }, "queue": { "command": ["pam", "artisan", "queue:work", "--sleep=1", "--tries=3"], "instances": 1 }, "scheduler": { "command": ["pam", "artisan", "schedule:work"], "instances": 1 } }}Commands are arrays, not shell strings, so arguments cannot be injected. Process
names must match ^[a-z][a-z0-9_-]*$; instances are clamped to 1..128.
Manage it with pam:process:
pam artisan pam:process up # start every stopped instancepam artisan pam:process up queue # start one processpam artisan pam:process statuspam artisan pam:process restart queuepam artisan pam:process scale queue 4pam artisan pam:process logs queue 1 # print queue-1.logpam artisan pam:process stop+-----------+----------+---------+---------+| Process | Instance | PID | State |+-----------+----------+---------+---------+| http | 1 | 1055981 | running || queue | 1 | 1055983 | running || scheduler | 1 | 1055987 | running |+-----------+----------+---------+---------+How it works:
- Each instance runs detached, with output appended to
storage/logs/pam/<name>-<instance>.log. - PIDs are recorded in
storage/pam/processes/<name>-<instance>.pidtogether with the process start time from/proc, so a recycled PID is never mistaken for your process (Linux only). stopsendsSIGTERM, waits up toPAM_PROCESS_STOP_TIMEOUTseconds (default10), then sendsSIGKILL.scalestores overrides instorage/pam/processes/scale.json, then restarts that process with the new instance count.
Writable Storage
Section titled “Writable Storage”When releases are read-only, every role must share the same writable storage:
export PAM_LARAVEL_STORAGE_PATH=/var/lib/pampam start pam.php --workers 4PAM_LARAVEL_STORAGE_PATH is applied by pam.php. For Artisan processes, set
Laravel’s storage path the same way your application does (for example, a
symlinked storage directory in each release), so logs and cache files end up
in one place.
Framework Caches
Section titled “Framework Caches”Build Laravel’s caches in the release before starting any process:
pam artisan optimize # config, events, routes, viewsBecause workers boot once, a cached configuration is read once per worker
generation. After you change .env or config, rebuild the cache and reload the
workers (see zero-downtime reloads).
Queue workers and the scheduler must be restarted too:
pam artisan queue:restartNext Steps
Section titled “Next Steps”- Deploying Laravel: supervising every role in production.
- Autoscaling: scaling queue instances from metrics.