PHPackages                             juststeveking/os-process - 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. juststeveking/os-process

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

juststeveking/os-process
========================

A PHP Package to work with OS processes in an OOP way.

1.0.0(3y ago)761594MITPHPPHP ^8.1

Since Aug 25Pushed 3y ago2 watchersCompare

[ Source](https://github.com/JustSteveKing/os-process)[ Packagist](https://packagist.org/packages/juststeveking/os-process)[ RSS](/packages/juststeveking-os-process/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

OS Process
==========

[](#os-process)

This package is a wrapper around the Symfony Process component, and build up an API that is object-oriented and user-friendly.

Installation
------------

[](#installation)

```
composer require juststeveking/os-process
```

Usage
-----

[](#usage)

To start using this package, you first need to create an Abstraction for the process you want to use. I will walk you through this here:

We create an abstraction for Terraform:

```
use JustSteveKing\OS\Contracts\ProcessContract;

class Terraform implements ProcessContract
{
    //
}
```

The `ProcessContract` means that you have to implement a `build` method that will return a built Symfony Process that we can then run.

```
use JustSteveKing\OS\Contracts\CommandContract;
use JustSteveKing\OS\Contracts\ProcessContract;
use Symfony\Component\Process\Process;

class Terraform implements ProcessContract
{
    private CommandContract $command;

    public function build() : Process
    {
        return new Process(
            command: $this->command->toArgs(),
        );
    }
}
```

Let's create a Command now:

```
use JustSteveKing\OS\Contracts\CommandContract;

class TerraformCommand implements CommandContract
{
    public function __construct(
        public readonly array $args = [],
        public readonly null|string $executable = null,
    ) {}

    public function toArgs() : array
    {
        $executable = (new ExecutableFinder())->find(
            name: $this->executable ?? 'terraform',
        );

        if (null === $executable) {
            throw new InvalidArgumentException(
                message: "Cannot find executable for [$this->executable].",
            );
        }

        return array_merge(
            [$executable],
            $this->args,
        );
    }
}
```

Now we just need to build and assign this within our abstraction:

```
use JustSteveKing\OS\Contracts\CommandContract;
use JustSteveKing\OS\Contracts\ProcessContract;
use Symfony\Component\Process\Process;

class Terraform implements ProcessContract
{
    private CommandContract $command;

    public function apply(): Process
    {
        $this->command = new TerraformCommand(
            executable: 'terraform',
        );

        return $this->build();
    }

    public function build() : Process
    {
        return new Process(
            command: $this->command->toArgs(),
        );
    }
}
```

Now we are able to work with this process in our code:

```
$terraform = new Terraform();

$terraform->apply()->run(); // Will run `terraform apply` in an OS process.
```

You can also obtain information about the process

```
$terraform = new Terraform();

$process = $terraform->apply(); // The process variable contains an instance of Symfony\Component\Process

$process->run(); // run `terraform apply` in an OS process.

// Obtaining information about the process

$output = $process->getOutput(); // Output of the command
$error = $process->getErrorOutput(); // Error output
$commandLine = $process->getCommandLine(); // Obtaining the complete command
```

Getting real-time Process Output

```
$terraform = new Terraform();

$process = $terraform->apply(); // The process variable contains an instance of Symfony\Component\Process

$process->start(); // start `terraform apply` in an OS process. (start not run)

 $process->wait(function ($type, $buffer) {
        if (\Symfony\Component\Process\Process::ERR === $type) {
            echo 'ERR > '.$buffer;
        } else {
            echo 'OUT > '.$buffer;
        }
    });
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

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

1360d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a87fe82b349821ebd49cf57d65c4cd3e33ae0833222a8438d90fe8921ca899ea?d=identicon)[JustSteveKing](/maintainers/JustSteveKing)

---

Top Contributors

[![JustSteveKing](https://avatars.githubusercontent.com/u/6368379?v=4)](https://github.com/JustSteveKing "JustSteveKing (9 commits)")[![twltwk](https://avatars.githubusercontent.com/u/23269914?v=4)](https://github.com/twltwk "twltwk (1 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/juststeveking-os-process/health.svg)

```
[![Health](https://phpackages.com/badges/juststeveking-os-process/health.svg)](https://phpackages.com/packages/juststeveking-os-process)
```

###  Alternatives

[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5205.3M82](/packages/symplify-monorepo-builder)[spatie/typescript-transformer

This is my package typescript-transformer

3706.5M16](/packages/spatie-typescript-transformer)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[shivas/versioning-bundle

Symfony application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recommendations

1121.2M1](/packages/shivas-versioning-bundle)[eclipxe/cfdiutils

PHP Common utilities for Mexican CFDI 3.2, 3.3 &amp; 4.0

141129.9k6](/packages/eclipxe-cfdiutils)[shyim/danger-php

Port of danger to PHP

8544.9k](/packages/shyim-danger-php)

PHPackages © 2026

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