1: Daemon overview
The Phlo Daemon is an optional Node sidecar (phlo-daemon.js) that runs any Phlo target on a pool of resident workers. It is a generic engine: it knows nothing about WebSockets, tasks or any one feature. Phlo Realtime and the scheduler are built into the daemon; the runtime helpers reach it over local HTTP. Core Phlo works without it; the daemon is the layer that makes the heavy paths fast and powers the long-lived services.

1.1: Three ways Phlo runs code
Every routine in a Phlo app is a callable target (Class::method, object.method or a bare function). There are three ways it actually executes:
| Mode | What happens | When |
|---|---|---|
| In-process | A plain function or method call inside the current request. No new process. | The normal case: routes, views, models. |
| One-shot CLI | A fresh php app.php <target> process that boots the app, runs, and exits. |
A target invoked from cron, a deploy script, or an async helper with no daemon. One boot per call. |
| Pooled worker | A resident worker (started by the daemon) that booted the app once and answers calls over a pipe. No per-call boot. | The same targets, when the daemon is running. |
The first is just PHP. The second and third are the same target run out of band; the only difference is whether a fresh process boots each time (one-shot) or a warm worker is reused (pool). The daemon is what turns the one-shot path into the pooled path.
1.2: Why it is optional
The one-shot path means nothing hard depends on the daemon. Async helpers fall back to a subprocess; tasks fall back to cron; an app that only serves HTTP never needs it at all. So you can develop and deploy without the daemon, and switch it on where boot cost or realtime matters, with no change to your app code.
Run the daemon when an app:
- needs WebSockets (Phlo Realtime dispatches every socket event to it),
- schedules tasks without a cron entry, or
- has a hot path that fans out into many app calls per request (where booting a process per call would dominate).
1.3: What you wire
- A small config file that requires
phlo-daemon.jswith the port, the PHP binary, any scheduled tasks, and the websocket host→app map (the fourth argument); apps do not self-register. - Optionally the
daemonconstant in an app entrypoint, to route its runtime helpers onto the pool. - Run it under a process manager (pm2, systemd, supervisord).
The phlo-daemon repository is the source, and the Daemon chapter of the guide is the dense technical reference.