PQ ("peak"), automatically wrap blocking functions in an async child process and turn blocking functions into non-blocking promises, built on top of ReactPHP.
Once installed, you can use the following code turn any blocking function (such as PHP's built-in file_get_contents()
function) into a non-blocking one:
$file_get_contents = (new Clue\React\Pq\Executor($loop))->fun('file_get_contents');
$file_get_contents(__FILE__)->then(function (string $contents) {
echo $contents;
}, function (Exception $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
});
This project is currently under active development, you're looking at a temporary placeholder repository.
The code is available in early access to my sponsors here: https://github.com/clue-access/reactphp-pq
Do you sponsor me on GitHub? Thank you for supporting sustainable open-source, you're awesome! ❤️ Have fun with the code! 🎉
Seeing a 404 (Not Found)? Sounds like you're not in the early access group. Consider becoming a sponsor on GitHub for early access. Check out clue·access for more details.
This way, more people get a chance to take a look at the code before the public release.
Rock on 🤘
This project will be released under the permissive MIT license.
Did you know that I offer custom development services and issuing invoices for sponsorships of releases and for contributions? Contact me (@clue) for details.