PHPackages                             skillberto/command-handler - 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. skillberto/command-handler

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

skillberto/command-handler
==========================

Simple isolated command handler library.

v1.2(9y ago)078MITPHP

Since Feb 15Pushed 9y ago1 watchersCompare

[ Source](https://github.com/skillberto/command-handler)[ Packagist](https://packagist.org/packages/skillberto/command-handler)[ RSS](/packages/skillberto-command-handler/feed)WikiDiscussions master Synced yesterday

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

Command Handler
===============

[](#command-handler)

[![Build Status](https://camo.githubusercontent.com/673b7e711b0b36cbae93088de72731914d3842bb98e04c51c341defa081c5d9f/68747470733a2f2f7472617669732d63692e6f72672f736b696c6c626572746f2f636f6d6d616e642d68616e646c65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/skillberto/command-handler)

Install
-------

[](#install)

Install from composer:

```
$ composer require skillberto/command-handler "~1.0"

```

Authors and contributors
------------------------

[](#authors-and-contributors)

- [Norbert Heiszler](heiszler.norbert@gmail.com) (Creator, developer)

Usage
-----

[](#usage)

The following example show you how you can us it:

```
use Symfony\Component\Console\Output\ConsoleOutput;
use Skillberto\CommandHandler\CommandHandler;
use Skillberto\CommandHandler\Command;

$output = new ConsoleOutput();
$handler = new CommandHandler($output);
$handler->add( 'some commands' );

... or

$handler->addCommand(new Command('some commands'));
$handler->execute();

```

You can define collections too:

```
$handler->addCollection(array('some commands'));

... or

$handler->addCommands(array(new Command('some commands')));

```

If you want to skip a command if it's not required:

```
$handler->addSkippable('some commands');

... or

$handler->addCommand(new Command('some commands', false));

... or add more commands

$handler->addSkippableCollection( array( 'some commands' ) );

... or

$handler->addCommands(array(new Command('some commands', false)));

$handler->execute();

```

...after that you can get these commands:

```
$handler->getSkippedMessages();

```

But, if you don't skip a command, and it's not successful:

```
$handler->getErrorMessage();

```

Advanced usage
--------------

[](#advanced-usage)

### Prefix

[](#prefix)

The following example show you have can you use the prefix:

```
...

$handler = new CommandHandler($output, "php ");

... or

$handler = new CommandHandler($output);
$handler->addPrefix("php ");

... then

$handler->add("--version");
$handler->execute();

```

In this case, you will execute `php --version`.

### Timeout

[](#timeout)

It can be defined for each command, or only for some commands, or both of them.

```
$handler = new CommandHandler($output, "", 0.2);

... or

$handler = new CommandHandler($output);
$handler->setTimeout(0.2);

... then

$handler->addCommand(new Command("php --version", true, 0.3);
$handler->add('something');
$handler->execute();

```

In the previous example every command will have "0.2 seconds" for execution, except `php --version`, it has got "0.3 seconds".

Let's see how can you define group timeout:

```
$handler = new CommandHandler($output);
$handler->setTimeout(0.2);
$handler->addCollection(array('some command'));
$handler->setTimeout(0.3);
$handler->addCollection(array('some command'));
$handler->execute();

```

In this example the first collection have "0.2 seconds", the second "0.3 seconds".

### Handler injection, merge

[](#handler-injection-merge)

In some case, we need to define more then one handler, eg.: for different prefixes. But don't worry about it, we have got a useful method:

```
$handler_1->addHandler($handler_2);

```

It's good, but what will be with prefixes and timeout? For these problems, CommandHandler has got three different merge types: `MERGE_ALL, MERGE_NON, MERGE_NOT_DEFINED`The default is `MERGE_NON`, but you can change it:

```
$handler_1->addHandler($handler_2, CommandHandler::MERGE_ALL, CommandHandler::MERGE_NOT_DEFINED);

```

In the previous example prefix merge has got `MERGE_ALL` type, timeout has got `MERGE_NOT_DEFINED` type. `MERGE_ALL` means that `$handler_1` prefix / timeout will use for all of them. `MERGE_NOT_DEFINED` means that `$handler_1` prefix / timeout will use, if it's not defined for `$handler_2` command(s). `MERGE_NON` means that prefixes and timeouts will be separated.

### Callback

[](#callback)

You can define a callback for each execution:

```
...
use Symfony\Component\Process\Process;
use Skillberto\CommandHandler\Command;
...

$handler->execute(function(Progress $progress, Command $command) {
   //something more
});

```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

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

Every ~78 days

Total

4

Last Release

3553d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2433ba2d39deb8fb11ffd0c44b609b9f0137bf9f000665639dc000d5897b931a?d=identicon)[skillberto](/maintainers/skillberto)

---

Top Contributors

[![skillberto](https://avatars.githubusercontent.com/u/1987338?v=4)](https://github.com/skillberto "skillberto (36 commits)")

---

Tags

commandinstall

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/skillberto-command-handler/health.svg)

```
[![Health](https://phpackages.com/badges/skillberto-command-handler/health.svg)](https://phpackages.com/packages/skillberto-command-handler)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M19.5k](/packages/laravel-framework)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[illuminate/console

The Illuminate Console package.

13045.3M6.3k](/packages/illuminate-console)[helhum/typo3-console

A reliable and powerful command line interface for TYPO3 CMS

2959.3M238](/packages/helhum-typo3-console)[jolicode/castor

A lightweight and modern task runner. Automate everything. In PHP.

54642.4k4](/packages/jolicode-castor)[whatsdiff/whatsdiff

See what's changed in your project's dependencies

771.1k](/packages/whatsdiff-whatsdiff)

PHPackages © 2026

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