I'm looking for examples folks might have of running a web server via PHP CLI. I've always used PHP-FPM or and Apache module, but both are explicitly incompatible with the Parallel extension for PHP.

That's cool, but I have a legit reason to spawn a thread and want to combat the stated problems of using multithreading in a webserver application.

So any examples of `php sever.php` spawning a full server app would be super welcome.


I haven't used it yet, but you may want to look into Swoole. It's meant for this sort of thing. It's kind of like node for PHP.

@ericmann But, whenever I’ve had a need to spawn a thread in PHP, I’ve always done something like:

exec('php script.php 2>&1 >/dev/null &');

You can’t easily get a response from it, but it works, and I’ve used it on high-traffic sites without performance issues.

Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!