Answer the question
In order to leave comments, you need to log in
How to start a Thread in symfony 4?
Good day to all, the task arose to run in parallel the processing of some operations from the CLI written in symfony 4 the
server was built with zts support test examples Thread worked fine
(test examples)
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use App\Worker\Worker;
class TestCommand extends Command
{
protected function configure()
{
$this->setName('app:test')
->setDescription('Description)
->setHelp('help ')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$thread = new Worker();
$thread->start() && $thread->join();
}
}
namespace App\Worker;
class Worker extends \Thread
{
private $value;
private $executor;
public function __construct()
{
}
public function run()
{
echo "asd";
}
}
PHP Fatal error: Uncaught Exception: Serialization of 'Closure' is not allowed in [no active file]:0
Stack trace:
#0 {main}
thrown in [no active file] on line 0
/home/master/php-src- php-7.2.2/main/main.c(1248) : Bailed out without a bailout address!
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question