I cannot use monolog logger inside Thread method run.
class MyThread extends Thread
{
public function run()
{
echo 'hihi', PHP_EOL;
$log = new Logger('MyApp');
$log->pushHandler(
new StreamHandler('php://stdout', Logger::INFO)
);
$log->addInfo("hoho");
echo 'haha', PHP_EOL;
}
}
$thread = new MyThread();
if ($thread->start()) {
$thread->join();
echo 'hehe', PHP_EOL;
}
Output:
hihi
hehe
Here PHP pthreads and SQLite3 and here pthread Thread objects reset their state somebody says that I can only use objects inerited from Stackable, Thread or Worker inside my class inherited from Thread. But what if I cannot change Logger class? I cannot use it?
I want to clarify: I cannot use object not inherited from Stackable, Thread or Worker inside class inherited from Thread at all? It is very strange. In other languages I can.
Win 7 x64 Ultimate, php 7 32 bit with thread safety.