PHPackages                             firehed/workers - 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. firehed/workers

ActiveLibrary

firehed/workers
===============

1.0.0(8y ago)0120MITPHP

Since Jul 23Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Firehed/workers)[ Packagist](https://packagist.org/packages/firehed/workers)[ RSS](/packages/firehed-workers/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Workers
=======

[](#workers)

A library to manage worker processes in a run loop.

[![Build Status](https://camo.githubusercontent.com/d937bf7f08f05e54a1318401037c8463477442bafb80da24df3d8b9eec32ef0c/68747470733a2f2f7472617669732d63692e6f72672f466972656865642f776f726b6572732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Firehed/workers)

Worker Manager
--------------

[](#worker-manager)

At the heart of any run loop is the Worker Manager. It will track execution count, set up basic POSIX signal handling, and other basic infrastructure.

Worker Class
------------

[](#worker-class)

The actual tasks are performed by a Worker class - anything that implements `Firehed\Workers\Worker`.

### `getName(): string`

[](#getname-string)

This is an identifer for the type of worker. `return __CLASS__;` is a sensible implmentation, but may result in more work that desired when specifying the worker if running in the foreground.

### `getNice(): int`

[](#getnice-int)

The `nice` level for the process, which controls the overall system priority. A number between -20 and 20. -20 is the highest priority (don't go this high, or you could make the system unresponsive); +20 is the lowest priority. Return `Worker::NICE_DEFAULT` (0) to leave the priority unaffected.

### `getProcessTitle(): string`

[](#getprocesstitle-string)

If this value is not empty, the manager will attempt to update the process title that's visible in utilities like `top`. Does not work on all operating systems.

### `getRunLimit(): int`

[](#getrunlimit-int)

Exit the run loop after this many iterations. Useful to cleanly exit workers that may consume more memory than desirable. Return `Worker::RUN_LIMIT_UNLIMITED` to not enforce a limit.

Note that implementations should avoid relying this, although it's well understood that PHP code often leaves resources hanging when it was originally designed around the web's shared nothing "work once and die" model.

### `work(): bool`

[](#work-bool)

Perform the actual work. This should fetch a single job and perform it. Implementations may read a row out of a database, grab a job out of a work queue, etc.

The worker's `work()` method should only return `false` if no work was attempted (nothing in the queue, etc). It should still return `true` if work was attempted and failed.

Using in Docker: Foreground Worker
----------------------------------

[](#using-in-docker-foreground-worker)

Call `WorkerManager->runInForeground($name)` to run a single worker in the foreground. This is ideal for applications designed around containerization (Docker) where some higher-level process manager already exists.

It is highly recommended to create a single worker script and corresponding container, and control which worker to run with a CLI argument or environment variable.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

3211d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/354842?v=4)[Eric Stern](/maintainers/Firehed)[@Firehed](https://github.com/Firehed)

---

Top Contributors

[![Firehed](https://avatars.githubusercontent.com/u/354842?v=4)](https://github.com/Firehed "Firehed (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/firehed-workers/health.svg)

```
[![Health](https://phpackages.com/badges/firehed-workers/health.svg)](https://phpackages.com/packages/firehed-workers)
```

PHPackages © 2026

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