frankenphp
frankenphp copied to clipboard
Feat: non-http workers
This PR is an alternative to #1883. It re-uses the worker logic in a non-http context by skipping globals registration.
worker /path/to/non-http-worker.php {
http_disabled
}
// any php script
frankenphp_send_request('hello');
// non-http-worker.php
while (frankenphp_handle_request(function ($message) {
echo $message; //hello
})) {}
non-http workers scale and restart like workers. It would also be nice if frankenphp_send_request returned a future that can be awaited, which is not yet in this PR.
@dunglas WDYT about this solution. It's less code, but mixes the worker implementations more together.
Or would you rather have frankenphp_send_request() in extensions? I think it would unlock a lot of potential use cases, but it would probably need to return a Future/Promise and I'm not sure where PHP is currently heading in terms of async/parallelism.