PHPackages                             zenstruck/console-extra - 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. zenstruck/console-extra

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

zenstruck/console-extra
=======================

A modular set of features to reduce configuration boilerplate for your Symfony commands.

v2.0.0(5mo ago)8057.6k↓30.8%3[11 issues](https://github.com/zenstruck/console-extra/issues)1MITPHPPHP &gt;=8.1CI passing

Since Oct 26Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/zenstruck/console-extra)[ Packagist](https://packagist.org/packages/zenstruck/console-extra)[ Docs](https://github.com/zenstruck/console-extra)[ GitHub Sponsors](https://github.com/kbond)[ GitHub Sponsors](https://github.com/nikophil)[ RSS](/packages/zenstruck-console-extra/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (16)Used By (1)

zenstruck/console-extra
=======================

[](#zenstruckconsole-extra)

[![CI](https://github.com/zenstruck/console-extra/actions/workflows/ci.yml/badge.svg)](https://github.com/zenstruck/console-extra/actions/workflows/ci.yml)[![codecov](https://camo.githubusercontent.com/90a4d662eea977138408f7f5f45043ee9aa58ca29efe0217f6dabb4531bac5d9/68747470733a2f2f636f6465636f762e696f2f67682f7a656e73747275636b2f636f6e736f6c652d65787472612f6272616e63682f312e782f67726170682f62616467652e7376673f746f6b656e3d4f45465041353354444d)](https://codecov.io/gh/zenstruck/console-extra)

A modular set of features to reduce configuration boilerplate for your Symfony commands:

```
#[AsCommand('create:user', 'Creates a user in the database.')]
final class CreateUserCommand extends InvokableServiceCommand
{
    use RunsCommands, RunsProcesses;

    public function __invoke(
        IO $io,

        UserManager $userManager,

        #[Argument]
        string $email,

        #[Argument]
        string $password,

        #[Option(name: 'role', shortcut: 'r', suggestions: UserMananger::ROLES)]
        array $roles,
    ): void {
        $userManager->createUser($email, $password, $roles);

        $this->runCommand('another:command');
        $this->runProcess('/some/script');

        $io->success('Created user.');
    }
}
```

```
bin/console create:user kbond p4ssw0rd -r ROLE_EDITOR -r ROLE_ADMIN

 [OK] Created user.

 // Duration: run(); // int (the status after running the command)

// pass arguments
CommandRunner::for($command, 'arg --opt')->run(); // int
```

If the application is available, you can use it to run commands:

```
use Zenstruck\Console\CommandRunner;

/** @var \Symfony\Component\Console\Application $application */

CommandRunner::from($application, 'my:command')->run();

// pass arguments/options
CommandRunner::from($application, 'my:command arg --opt')->run(); // int
```

If your command is interactive, you can pass inputs:

```
use Zenstruck\Console\CommandRunner;

/** @var \Symfony\Component\Console\Application $application */

CommandRunner::from($application, 'my:command')->run([
    'foo', // input 1
    '', // input 2 ()
    'y', // input 3
]);
```

By default, output is suppressed, you can optionally capture the output:

```
use Zenstruck\Console\CommandRunner;

/** @var \Symfony\Component\Console\Application $application */

$output = new \Symfony\Component\Console\Output\BufferedOutput();

CommandRunner::from($application, 'my:command')
    ->withOutput($output) // any OutputInterface
    ->run()
;

$output->fetch(); // string (the output)
```

#### `RunsCommands`

[](#runscommands)

You can give your [Invokable Commands](#invokablecommand) the ability to run other commands (defined in the application) by using the `RunsCommands` trait. These *sub-commands* will use the same *output* as the parent command.

```
use Symfony\Component\Console\Command;
use Zenstruck\Console\InvokableCommand;
use Zenstruck\Console\RunsCommands;

class MyCommand extends InvokableCommand
{
    use RunsCommands;

    public function __invoke(): void
    {
        $this->runCommand('another:command'); // int (sub-command's run status)

        // pass arguments/options
        $this->runCommand('another:command arg --opt');

        // pass inputs for interactive commands
        $this->runCommand('another:command', [
            'foo', // input 1
            '', // input 2 ()
            'y', // input 3
        ])
    }
}
```

### `RunsProcesses`

[](#runsprocesses)

You can give your [Invokable Commands](#invokablecommand) the ability to run other processes (`symfony/process` required) by using the `RunsProcesses` trait. Standard output from the process is hidden by default but can be shown by passing `-v` to the *parent command*. Error output is always shown. If the process fails, a `\RuntimeException`is thrown.

```
use Symfony\Component\Console\Command;
use Symfony\Component\Process\Process;
use Zenstruck\Console\InvokableCommand;
use Zenstruck\Console\RunsProcesses;

class MyCommand extends InvokableCommand
{
    use RunsProcesses;

    public function __invoke(): void
    {
        $this->runProcess('/some/script');

        // construct with array
        $this->runProcess(['/some/script', 'arg1', 'arg1']);

        // for full control, pass a Process itself
        $this->runProcess(
            Process::fromShellCommandline('/some/script')
                ->setTimeout(900)
                ->setWorkingDirectory('/')
        );
    }
}
```

### `CommandSummarySubscriber`

[](#commandsummarysubscriber)

Add this event subscriber to your `Application`'s event dispatcher to display a summary after every command is run. The summary includes the duration of the command and peak memory usage.

If using Symfony, configure it as a service to enable:

```
# config/packages/zenstruck_console_extra.yaml

services:
    Zenstruck\Console\EventListener\CommandSummarySubscriber:
        autoconfigure: true
```

Note

This will display a summary after every registered command runs.

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance75

Regular maintenance activity

Popularity44

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 96.8% 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 ~104 days

Recently: every ~182 days

Total

16

Last Release

92d ago

Major Versions

v0.2.0 → v1.0.02022-04-08

v1.4.1 → v2.0.02025-12-07

PHP version history (3 changes)v0.1.0PHP &gt;=7.4

v1.2.0PHP &gt;=8.0

v1.4.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/707369cc916e0ea1aacbf077dcba464f611cef879f024d8944311a54a15224b3?d=identicon)[kbond](/maintainers/kbond)

---

Top Contributors

[![kbond](https://avatars.githubusercontent.com/u/127811?v=4)](https://github.com/kbond "kbond (120 commits)")[![tacman](https://avatars.githubusercontent.com/u/619585?v=4)](https://github.com/tacman "tacman (3 commits)")[![jdreesen](https://avatars.githubusercontent.com/u/424602?v=4)](https://github.com/jdreesen "jdreesen (1 commits)")

---

Tags

consolesymfonycommand

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/zenstruck-console-extra/health.svg)

```
[![Health](https://phpackages.com/badges/zenstruck-console-extra/health.svg)](https://phpackages.com/packages/zenstruck-console-extra)
```

###  Alternatives

[matthiasnoback/symfony-console-form

Use Symfony forms for Console command input

368264.8k8](/packages/matthiasnoback-symfony-console-form)[laminas/laminas-cli

Command-line interface for Laminas projects

563.7M54](/packages/laminas-laminas-cli)[fidry/console

Library to create CLI applications

192.0M4](/packages/fidry-console)

PHPackages © 2026

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