PHPackages                             posternak/commandeer - 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. [CLI &amp; Console](/categories/cli)
4. /
5. posternak/commandeer

ActiveLibrary[CLI &amp; Console](/categories/cli)

posternak/commandeer
====================

A fluent API to execute shell commands.

0.1.0(1mo ago)10MITPHPPHP ^8.4CI passing

Since Jun 10Pushed 1mo agoCompare

[ Source](https://github.com/Androoha1/Commandeer)[ Packagist](https://packagist.org/packages/posternak/commandeer)[ RSS](/packages/posternak-commandeer/feed)WikiDiscussions main Synced 1w ago

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

Commandeer
==========

[](#commandeer)

A fluent PHP API for building and executing shell commands programmatically, for taking them under control, or in other words - commandeer them.

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

[](#installation)

Install it into your project with composer:

```
composer require posternak/commandeer
```

Overview
--------

[](#overview)

Commandeer provides a type-safe, fluent API for constructing and executing shell commands in PHP, replacing error-prone string concatenation with chainable method calls.

ShellCommand Class
------------------

[](#shellcommand-class)

The foundation class that executes commands and captures results:

```
use Posternak\Commandeer\ShellCommand;

$command = new ShellCommand('git status');
$command->run();

if ($command->succeeded()) {
    $output = $command->getOutput(); // array of lines
}
```

**API:**

- `run(): self` - Execute the command
- `succeeded(): bool` - Check if exit code was 0
- `getOutput(): array` - Get output lines
- `getCommand(): string` - Get command string

Cmd Builder - Universal Command Builder
---------------------------------------

[](#cmd-builder---universal-command-builder)

The `Cmd` class provides a universal interface for building any shell command, it's the fluent API. To construct a command:

1. Start with the `Cmd` class.
2. Call a static method whose name matches your desired executable (e.g., `Cmd::docker()` for the `docker` executable).
3. Chain additional methods for CLI options and arguments, passing data as method parameters.

Method names are automatically converted to command-line syntax (underscores become dashes), and method arguments become command parameters.

**Examples:**

```
use Posternak\Commandeer\Builders\Cmd;

// docker ps -a
Cmd::docker()->ps()->_a()->run();

// kubectl get pods -o json
Cmd::kubectl()->get('pods')->_o('json')->run();

// npm install
Cmd::npm()->install()->run();

// git log --pretty oneline
Cmd::git()->log()->pretty('oneline')->run();
```

**API:**

- `Cmd::{executable}()` - Start building a command for any executable
- `->{method}()` - Add command arguments (underscores become dashes)
- `->run()` - Execute the command
- `->getCommand()` - Preview command string without executing

Predefined Builders
-------------------

[](#predefined-builders)

For commonly-used tools, predefined builders eliminate the need to specify the executable name:

```
use Posternak\Commandeer\Builders\Git;
use Posternak\Commandeer\Builders\Composer;

// Instead of Cmd::git()
Git::status()->porcelain()->run();

// Instead of Cmd::composer()
Composer::require('vendor/package')->run();
```

**Available builders:** `Git`, `Composer`, `Rector`, `PHPStan`, `PHPCsFixer`, `Php`, `Artisan`

Git Convenience Methods
-----------------------

[](#git-convenience-methods)

The Git builder includes shortcuts for common operations:

```
Git::addEverything(); // git add .
Git::commitWithMessage('feat: add feature'); // git commit -m "..."
Git::pushToOrigin('main'); // git push origin main
```

Interactive Shell (REPL)
------------------------

[](#interactive-shell-repl)

Commandeer ships with an interactive shell for exploring and running commands without writing a PHP script. All builder classes are available automatically — no `use` statements needed.

```
vendor/bin/commandeer
```

Type `help` once inside to get started.

License
-------

[](#license)

MIT

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance90

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

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

Unknown

Total

1

Last Release

46d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/147425231?v=4)[androoha](/maintainers/androoha)[@Androoha](https://github.com/Androoha)

---

Top Contributors

[![Androoha1](https://avatars.githubusercontent.com/u/162342931?v=4)](https://github.com/Androoha1 "Androoha1 (62 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Type Coverage Yes

### Embed Badge

![Health badge](/badges/posternak-commandeer/health.svg)

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

###  Alternatives

[illuminate/console

The Illuminate Console package.

13046.0M6.8k](/packages/illuminate-console)[styleci/cli

The CLI tool for StyleCI

71470.5k9](/packages/styleci-cli)[winbox/args

Windows command-line formatter

20720.9k21](/packages/winbox-args)[mallardduck/laravel-traits

A collection of useful Laravel snippets in the form of easy to use traits.

136.2k2](/packages/mallardduck-laravel-traits)

PHPackages © 2026

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