gistfile1.txt
· 617 B · Text
Ham
The Basic Anatomy of a Fiber
The beauty of PHP Fibers is in their simplicity. Here’s how to create a fiber and get it up and running:
$fiber = new Fiber(function() {
echo "Fiber started…\n";
Fiber::suspend(); // Pause the fiber
echo "Fiber resumed…\n";
});
echo "Fiber starting…\n";
$fiber->start(); // Start the fiber
echo "Main script running…\n";
$fiber->resume(); // Resume the fiber
https://byteblog.medium.com/php-fibers-how-php-is-finally-warming-up-to-asynchronous-programming-39da4d21b8e7
https://itsimiro.medium.com/understanding-fibers-in-php-a-new-way-to-handle-concurrency-ed07424320ff
| 1 | The Basic Anatomy of a Fiber |
| 2 | The beauty of PHP Fibers is in their simplicity. Here’s how to create a fiber and get it up and running: |
| 3 | |
| 4 | $fiber = new Fiber(function() { |
| 5 | echo "Fiber started…\n"; |
| 6 | Fiber::suspend(); // Pause the fiber |
| 7 | echo "Fiber resumed…\n"; |
| 8 | }); |
| 9 | echo "Fiber starting…\n"; |
| 10 | $fiber->start(); // Start the fiber |
| 11 | echo "Main script running…\n"; |
| 12 | $fiber->resume(); // Resume the fiber |
| 13 | |
| 14 | https://byteblog.medium.com/php-fibers-how-php-is-finally-warming-up-to-asynchronous-programming-39da4d21b8e7 |
| 15 | https://itsimiro.medium.com/understanding-fibers-in-php-a-new-way-to-handle-concurrency-ed07424320ff |
| 16 |