vuongxuongminh / laravel-async

Package provide simple way to run code asynchronously for your Laravel application.
MIT License
154 stars 26 forks source link

Not working with Laravel Sail #24

Closed benfiratkaya closed 1 year ago

benfiratkaya commented 2 years ago

Hello I'm using Laravel Sail. Because I'm Windows user and laravel-async not working with Windows.

When I send async mail, mail not sending. No problem with sync.

My Code:

use Async;

Async::run(function () use ($email, $token) {
  Mail::to($email)->send(new ForgotPassword($token));
});

Also not working:

use Async;

for ($i = 1; $i < 20; $i++) {
  Async::run(function () use ($i) {
    sleep(1);

    return $i;
  });
}

dd(implode(', ', Async::wait()));

Output: ""

Laravel Version: 8.78 OS: Ubuntu 21 PCNTL Enabled.

# php -i | grep pcntl
pcntl support => enabled     

No error with:

Async::run(function () {

}, [
  'error' => function (\Exception $e) {
    dd($e);
  }
]);
vuongxuongminh commented 1 year ago

Please try the latest version and make sure your PHP extensions have POSIX and PCNTL.