I want to create a thread using Fiber (PHP 8.1) to send an email (email sending takes 10 seconds, so I decide to use a thread for it). And this is my code
<?php
$fiber = new Fiber(function () {
send_email();
});
$fiber->start();
exit(json_encode(['response' => 1]));
The result of send_email() is not important but after start the fiber, fiber waits until send_email() done then exit(json_encode(['response' => 1])); happen !!!! I want it to exit immediately, but send email too !!!
what is the problem?