Proof of concept of asynchronous programming with Php 8.1 and Fiber.
Slip (pronounced like "sleep" in english) is a nano framework providing a non-blocking sleep function.
Slip has been presented in a short talk at ForumPhp 2021 (fr).
Don't.
It's just a one file library for demonstration purpose only.
If you want to try it in your own project, just copy the Slip.php file.
Slip contains only 3 (documented) functions:
- wrap several functions in some
Slip\Slipperobjects - use
Slip\sleep()to pause your functions in a non-blocking way - run your
Slip\Slipperinstances concurrently withSlip\Slipper::run().
Some examples are provided, using a Ping Pong analogy.
A ping and a pong functions are executed concurrently in a vanilla Php program.
A small program using Symfony Console Component,
providing a ping and a pong commands.
First, run composer install to install dependencies, then you can execute commands individually (with
php console.php <cmd> <count>) or concurrently (with php console.php ping-pong <count>).
Previous example launches 1 application with several concurrent commands,
but this one launches several concurrent applications with a single command.
Be sure to install dependencies, then run it with php ping-pong.php.
It's a lame french joke, no offense… We are not looking for a logo.