PHPackages                             programster/runnable - 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. programster/runnable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

programster/runnable
====================

A package for making runnable objects.

1.0.0(11mo ago)028MITPHPPHP &gt;=8.2.0

Since Jul 25Pushed 11mo agoCompare

[ Source](https://github.com/programster/package-runnable)[ Packagist](https://packagist.org/packages/programster/runnable)[ Docs](https://github.com/programster/package-core-libs)[ RSS](/packages/programster-runnable/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (3)Used By (0)

Runnable Package
================

[](#runnable-package)

This is a basic package for building runnable objects or background jobs.

Example Usage
-------------

[](#example-usage)

Here is an example of creating a "job" that extends the runnable class:

```
use \Programster\Runnable\Runnable;

class Job extends Runnable
{
    public function __construct(private readonly string $name){}

    public function run() : void
    {
        echo "hello {$this->name}" . PHP_EOL;
    }
}

$job = new Job("Susan");
```

You can now execute the job by doing any of the following:

```
// calling the run method.
$job->run();

// invoking it directly.
$job()

// passing it as a callback.
function executor(callable $callback)
{
    $callback();
}

executor($job)
```

You could even create an executor that takes any number of callbacks and executes them like so:

```
class JobExecutor() extends Runnable
{
    public function __construct(private readonly callable ...$jobs)
    {

    }

    public function run() : void
    {
        foreach ($this->jobs as $job)
        {
            $job();
        }
    }
}

$executor = new JobExecutor(
    new Job("Tom"),
    new Job("Harry"),
    function() { echo "do something...\n"; },
)

$executor->run();
```

### JSON Serializing Runnable Objects

[](#json-serializing-runnable-objects)

If you are thinking of storing jobs in a queue that is executed by some background process, then you may wish to use the JsonSerializableRunnable class:

```
use \Programster\Runnable\JsonSerializableRunnable;

class Job extends JsonSerializableRunnable
{
    public function __construct(private readonly string $name){}

    public function run() : void
    {
        echo "hello {$this->name}" . PHP_EOL;
    }

    public static function jsonUnserialize(string $jsonForm): static
    {
        $arrayForm = json_decode($jsonForm, true);
        return new Job($arrayForm['name']);
    }

    public function jsonSerialize(): mixed
    {
        return [
            'name' => $this->name,
        ];
    }
}

$job = new Job("Susan");
$jsonForm = json_encode($job->jsonSerialize());
// save to database here...

// retrieve from database and create from the JSON form:
$job = Job::jsonUnserialize($jsonForm);

// execute as normal.
caller($job);
```

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance51

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 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

Every ~0 days

Total

2

Last Release

344d ago

Major Versions

0.1.0 → 1.0.02025-07-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/64a048ca8be761aced9419279975a21ef679b71c70d8263bc2fc413a87ad381c?d=identicon)[programster](/maintainers/programster)

---

Top Contributors

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

---

Tags

runnable

### Embed Badge

![Health badge](/badges/programster-runnable/health.svg)

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

###  Alternatives

[nfephp-org/sped-efinanceira

e-Financeira library

151.7k](/packages/nfephp-org-sped-efinanceira)

PHPackages © 2026

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