Closed valh1996 closed 4 years ago
Hi, Make sure you are using Async
facade not call direct to VXM\Async\Async
. Yes, you can call all functions of Laravel in child process.
Thanks! So I can use all the functions of Laravel inside the child process, but we agree that it is not shared with the parent process? I have a singleton that I would like to "duplicate" (not the same user id) in the child process to make it communicate with the one in the parent process. I don't know if it's clear
Here is my complete new code :
<?php
namespace App\Console\Commands;
use Async;
use VXM\Async\Invocation;
class MyTask
{
use Invocation;
public function handle()
{
return 1;
}
}
class test extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'test';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
Async::run(MyTask::class, [
'success' => function ($output) {
echo $output;
},
'error' => function (\Throwable $e) {
var_dump($e->getMessage()); die;
}
]);
return true;
}
}
I'm getting an empty error each time :
$: php artisan test
string(0) ""
Do you know why please? I can't get this piece of code to work :(
Task should be PSR-4 named, can you rename and try again?
Hello,
Whatever I do, your example gives me an error :
"exception": "Non-static method VXM\\Async\\Async::run() should not be called statically"
Here is my code based on your example :
Do you have any idea please ?
Is it possible to use all the functions of Laravel in the child process please?
PS : Is it also possible to keep the child process open while the parent process has not been completed?
Thank you Val'