Control processes in GNU/Linux systems by this package for PHP 8.x
Install it by Composer
> composer require milanowicz/php-threadClass to control thread for one command
$thread = new Milanowicz\Thread\Threads();
$thread->exec('php scripts/script1.php');
$thread->exec('php scripts/script2.php');
$thread->anyRunning();
$thread->stopAll();
$thread->reset();Worker to run commands
$worker = new Milanowicz\Thread\Worker([
'command' => '/bin/sleep 2',
'execMaxCounter' => 10, // How many would you execute?
'maxWorkers' => 2, // How process(es) should be started?
'maxExecutionTime' => 120, // Seconds to run php script
'memoryLimit' => '32M', // Maximum for php memory limit
'workerDelayStart' => 1, // Delay for starting processes after each other
'workerRunSleep' => 2, // Sleep to check again if enough processes are running
]);
$worker->setCheckDispatcher(function () { return <bool>; });
$worker->run(); // Main call to start worker loop
$worker->getThread(); // Get current Thread instanceSingleton to control it everywhere you like
$singleton = new Milanowicz\Thread\ThreadSingleton();
$singleton->exec('php scripts/script1.php');
$singleton->exec('php scripts/script2.php');
$singleton->anyRunning();
$singleton->stopAll();
$singleton->resetWorker and Singleton
$worker = new Milanowicz\Thread\Worker([
'command' => '/bin/sleep 20',
'execMaxCounter' => 10, // How many would you execute?
'maxWorkers' => 2, // How process(es) should be started?
], new Milanowicz\Thread\ThreadSingleton());
$worker->run();Run all test suites
> composer testsRun PHP Code Styling
> composer styleRun PHPStan to analyze code
> composer analyzeRun PHPUnit tests
> composer testRun Mutation tests by Infection
> composer infection