Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncFacade::run function issue #35

Open
carlosMartin0213 opened this issue Apr 24, 2023 · 1 comment
Open

AsyncFacade::run function issue #35

carlosMartin0213 opened this issue Apr 24, 2023 · 1 comment

Comments

@carlosMartin0213
Copy link

carlosMartin0213 commented Apr 24, 2023

I read your ReadMe and installed laravel-async to my current project.
All things are worked well, but only one problem is occured.
It is running synchronously.

use VXM\Async\AsyncFacade as Async;
for ($i = 1; $i < 20; $i++) {
    Async::run(function () use ($i) {
        sleep(1);
        return $i;
    });
}
var_dump(implode(', ', Async::wait()));

And run following command to add config file, and asyn.php like your code is added to config directory.
php artisan vendor:publish --provider="VXM\Async\AsyncServiceProvider" --tag="config"

After running this code, I can get result like this.
"string(65) "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19"
Is there anything I need to configure my project to run asynchronously?
Thanks.

@carlosMartin0213 carlosMartin0213 changed the title AsyncFacade run function issue AsyncFacade::run function issue Apr 24, 2023
@kirkbushell
Copy link

@carlosMartin0213 as per the underlying library: https://github.com/spatie/async

You're probably missing the posix and pcntl extensions required in PHP to make it work. With that library, it falls back to synchronous by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants