You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Starts a sidekick worker. The configured `sidekick_entrypoint` script is executed
34
+
in a new PHP thread with the given `$argv` available in `$_SERVER['argv']`.
35
+
36
+
-**At-most-once by name**: calling it multiple times with the same `$name` is a no-op (safe with multiple HTTP workers)
37
+
-**`$argv`**: must be an array of strings; available as `$_SERVER['argv']` in the sidekick script (with the script path prepended as `argv[0]`, like CLI)
38
+
- Throws `ValueError` if `$name` is empty
39
+
- Throws `InvalidArgumentException` if `$argv` contains non-string values
40
+
- Throws `RuntimeException` if no `sidekick_entrypoint` is configured or no thread is available
-**Shebang support**: entrypoints with `#!/usr/bin/env php` are handled correctly
137
+
-**Crash recovery**: if a sidekick script exits, FrankenPHP restarts it automatically (using the existing worker restart logic with exponential backoff)
138
+
-**Graceful shutdown**: sidekicks detect shutdown via `frankenphp_sidekick_should_stop()` and exit their loop
139
+
-**`SCRIPT_FILENAME`**: set to the entrypoint's full path, so `dirname(__DIR__)` works correctly
140
+
-**`$_SERVER['argv']`**: follows CLI conventions — `argv[0]` is the script path, followed by the arguments passed to `frankenphp_sidekick_start()`
141
+
142
+
## Debugging
143
+
144
+
- Use `error_log()` or `frankenphp_log()` for structured output — these go through FrankenPHP's logger
145
+
- Avoid `echo` in sidekicks — it produces unstructured, unattributed log entries
146
+
- Sidekick scripts can be tested standalone: `php bin/sidekick.php`
0 commit comments