PHPackages                             milanowicz/php-thread - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. milanowicz/php-thread

ActivePhp-library[Utility &amp; Helpers](/categories/utility)

milanowicz/php-thread
=====================

Library for Thread(s) in GNU/Linux Systems

1.0.2(1y ago)27GPL-3.0-or-laterPHPPHP ^8.0CI passing

Since Mar 1Pushed 1w ago1 watchersCompare

[ Source](https://github.com/milanowicz/php-thread)[ Packagist](https://packagist.org/packages/milanowicz/php-thread)[ RSS](/packages/milanowicz-php-thread/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (6)Versions (8)Used By (0)

PHP Thread
==========

[](#php-thread)

[![Test](https://github.com/milanowicz/php-thread/workflows/Testing/badge.svg?branch=master)](https://github.com/milanowicz/php-thread/workflows/Testing/badge.svg?branch=master)[![Mutation testing](https://camo.githubusercontent.com/166d610d444b0a24dcb2ac053b7085ceef46a25fddcf06921d7d7c985e8b061e/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d2532466d696c616e6f7769637a2532467068702d7468726561642532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/milanowicz/php-thread/master)[![codecov](https://camo.githubusercontent.com/373440509f067f6f26a924b36d57e2b7ccaf6769a371a968a24f33c6afbfa180/68747470733a2f2f636f6465636f762e696f2f67682f6d696c616e6f7769637a2f7068702d7468726561642f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d34324736455449394e56)](https://codecov.io/gh/milanowicz/php-thread)

[![](https://camo.githubusercontent.com/05f2b5a4c008795269873532a81f0d5277d9f567498ba383ac6cffb531fddc31/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d696c616e6f7769637a2f7068702d746872656164)](https://camo.githubusercontent.com/05f2b5a4c008795269873532a81f0d5277d9f567498ba383ac6cffb531fddc31/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d696c616e6f7769637a2f7068702d746872656164)[![](https://camo.githubusercontent.com/7a6800739342935e7fea04e82fc54e805714774a4a8f85e9b5cfa3173e89edf8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f746f702f6d696c616e6f7769637a2f7068702d746872656164)](https://camo.githubusercontent.com/7a6800739342935e7fea04e82fc54e805714774a4a8f85e9b5cfa3173e89edf8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f746f702f6d696c616e6f7769637a2f7068702d746872656164)

[![](https://camo.githubusercontent.com/db9b1228dfd5886cff54cae635e5c52c3ed637bf4ffdcd257def8b4519bceaa0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f6d696c616e6f7769637a2f7068702d746872656164)](https://camo.githubusercontent.com/db9b1228dfd5886cff54cae635e5c52c3ed637bf4ffdcd257def8b4519bceaa0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f6d696c616e6f7769637a2f7068702d746872656164)[![](https://camo.githubusercontent.com/8f64da549c2f35ca1c2f02bf8f41a7d13609339e6eb67aae6b4d2018bbf85ecb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f6d696c616e6f7769637a2f7068702d746872656164)](https://camo.githubusercontent.com/8f64da549c2f35ca1c2f02bf8f41a7d13609339e6eb67aae6b4d2018bbf85ecb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f6d696c616e6f7769637a2f7068702d746872656164)[![](https://camo.githubusercontent.com/1c1aede08b125150df3ab07cd0b48afe7a42caf1eece753d2b7d79b2cc0ce7bd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f6d696c616e6f7769637a2f7068702d746872656164)](https://camo.githubusercontent.com/1c1aede08b125150df3ab07cd0b48afe7a42caf1eece753d2b7d79b2cc0ce7bd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f6d696c616e6f7769637a2f7068702d746872656164)

[![](https://camo.githubusercontent.com/02827e794003c762c16c89c72fa6922b3a2ca587d8c085a79bab1acf8ca164fd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d696c616e6f7769637a2f7068702d746872656164)](https://camo.githubusercontent.com/02827e794003c762c16c89c72fa6922b3a2ca587d8c085a79bab1acf8ca164fd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d696c616e6f7769637a2f7068702d746872656164)[![](https://camo.githubusercontent.com/e91e927cebb52d6ba598ba56f78f1768e0f2621902fb815148d627a7be882532/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d696c616e6f7769637a2f7068702d746872656164)](https://camo.githubusercontent.com/e91e927cebb52d6ba598ba56f78f1768e0f2621902fb815148d627a7be882532/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d696c616e6f7769637a2f7068702d746872656164)[![](https://camo.githubusercontent.com/2e30c04553aaf8ecc927b8a5c1ea14830882b0e2bf28f2a3f7cd9d862a3fee27/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64642f6d696c616e6f7769637a2f7068702d746872656164)](https://camo.githubusercontent.com/2e30c04553aaf8ecc927b8a5c1ea14830882b0e2bf28f2a3f7cd9d862a3fee27/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64642f6d696c616e6f7769637a2f7068702d746872656164)[![](https://camo.githubusercontent.com/e7b6381f6a02dfd8d58b1ad664e72184ce106c44e45427cb6304682d740e860b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6d696c616e6f7769637a2f7068702d746872656164)](https://camo.githubusercontent.com/e7b6381f6a02dfd8d58b1ad664e72184ce106c44e45427cb6304682d740e860b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6d696c616e6f7769637a2f7068702d746872656164)

Control processes in GNU/Linux systems by this package for PHP 8.x

Usage
-----

[](#usage)

Install it by Composer

```
> composer require milanowicz/php-thread
```

Class 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 ; });
$worker->run(); // Main call to start worker loop

$worker->getThread(); // Get current Thread instance
```

Singleton 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->reset
```

Worker 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();
```

Development
-----------

[](#development)

Run all test suites

```
> composer tests
```

Run PHP Code Styling

```
> composer style
```

Run PHPStan to analyze code

```
> composer analyze
```

Run PHPUnit tests

```
> composer test
```

Run Mutation tests by Infection

```
> composer infection
```

License
-------

[](#license)

[GNU GPL Version 3](http://www.gnu.org/copyleft/gpl.html)

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance74

Regular maintenance activity

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~540 days

Total

3

Last Release

455d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/717cb11cf3478a2c0893028c749e9659881770a1af71a2a98764fac08a081ae7?d=identicon)[milanowicz](/maintainers/milanowicz)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (340 commits)")[![milanowicz](https://avatars.githubusercontent.com/u/1786103?v=4)](https://github.com/milanowicz "milanowicz (84 commits)")

---

Tags

phpthreadthread-librarythreads

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/milanowicz-php-thread/health.svg)

```
[![Health](https://phpackages.com/badges/milanowicz-php-thread/health.svg)](https://phpackages.com/packages/milanowicz-php-thread)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
