Closed santossoares closed 1 year ago
I have a code that i need to echo from the child process. Is it possible to make the echo print on the console?
<?php
require_once "vendor/autoload.php";
use Spatie\Async\Pool;
$pool = Pool::create();
$pool->add(function () { for ($i = 0; $i < 5; $i++) { echo $i; sleep(1); } return 'end'; })->then(function ($output) { echo "Status $output" . PHP_EOL; });
$pool->wait();
I also have a use case for this.
You can't - you need to use Laravel's logger. The output doesn't get captured, but the result is.
I have a code that i need to echo from the child process. Is it possible to make the echo print on the console?
<?php
require_once "vendor/autoload.php";
use Spatie\Async\Pool;
$pool = Pool::create();
$pool->add(function () { for ($i = 0; $i < 5; $i++) { echo $i; sleep(1); } return 'end'; })->then(function ($output) { echo "Status $output" . PHP_EOL; });
$pool->wait();