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

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

fyre/command
============

A command library.

v7.0(7mo ago)0168↓84.6%5MITPHP

Since May 7Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/elusivecodes/FyreCommand)[ Packagist](https://packagist.org/packages/fyre/command)[ RSS](/packages/fyre-command/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (10)Versions (36)Used By (5)

FyreCommand
===========

[](#fyrecommand)

**FyreCommand** is a free, open-source CLI command library for *PHP*.

Table Of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Methods](#methods)
- [Commands](#commands)
    - [Aliases](#aliases)
    - [Options](#options)

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

[](#installation)

**Using Composer**

```
composer require fyre/command

```

In PHP:

```
use Fyre\Command\CommandRunner;
```

Basic Usage
-----------

[](#basic-usage)

- `$container` is a [*Container*](https://github.com/elusivecodes/FyreContainer).
- `$inflector` is an [*Inflector*](https://github.com/elusivecodes/FyreInflector).
- `$loader` is a [*Loader*](https://github.com/elusivecodes/FyreLoader).
- `$io` is a [*Console*](https://github.com/elusivecodes/FyreConsole).
- `$eventManager` is an [*EventManager*](https://github.com/elusivecodes/FyreEvent).
- `$typeParser` is an [*TypeParser*](https://github.com/elusivecodes/FyreTypeParser).

```
$runner = new CommandRunner($container, $inflector, $loader, $io, $eventManager, $typeParser);
```

**Autoloading**

It is recommended to bind the *CommandRunner* to the [*Container*](https://github.com/elusivecodes/FyreContainer) as a singleton.

```
$container->singleton(CommandRunner::class);
```

Any dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).

```
$runner = $container->use(CommandRunner::class);
```

Methods
-------

[](#methods)

**Add Namespace**

Add a namespace for loading commands.

- `$namespace` is a string representing the namespace.

```
$runner->addNamespace($namespace);
```

**All**

Get all available commands.

```
$commands = $runner->all();
```

**Clear**

Clear all namespaces and loaded commands.

```
$runner->clear();
```

**Get Namespaces**

Get the namespaces.

```
$namespaces = $runner->getNamespaces();
```

**Handle**

Handle an argv [*Command*](#commands).

- `$argv` is an array containing the CLI arguments.

```
$code = $runner->handle($argv);
```

**Has Command**

Determine whether a command exists.

- `$alias` is a string representing the command alias.

```
$hasCommand = $runner->hasCommand($alias);
```

**Has Namespace**

Determine whether a namespace exists.

- `$namespace` is a string representing the namespace.

```
$hasNamespace = $runner->hasNamespace($namespace);
```

**Remove Namespace**

Remove a namespace.

- `$namespace` is a string representing the namespace.

```
$runner->removeNamespace($namespace);
```

**Run**

Run a [*Command*](#commands).

- `$alias` is a string representing the command alias.
- `$arguments` is an array containing arguments for the command, and will default to *\[\]*.

```
$code = $runner->run($alias, $arguments);
```

Command [options](#options) will be parsed from the provided arguments.

Commands
--------

[](#commands)

Custom commands can be created by extending `\Fyre\Command\Command`, suffixing the class name with "*Command*", and ensuring a `run` method is implemented.

Any dependencies will be resolved automatically from the [*Container*](https://github.com/elusivecodes/FyreContainer).

The `run` method should return an integer representing the command exit code. The class constants `Command::CODE_SUCCESS` and `Command::CODE_ERROR` can be used.

### Aliases

[](#aliases)

You can define `$alias` and `$description` properties on the command. If no `$alias` is a provided, the command class name will be used (converted to snake\_case).

### Options

[](#options)

You can also define an `$options` array on your custom commands, which will be used by the *CommandRunner* to parse the arguments and prompt for input if required.

- `prompt` is a string representing the prompt text, and will default to "".
- `values` is an array containing the values, and will default to *null*.
- `required` is a boolean indicating whether a value must be provided, and will default to *false*.
- `as` is a string representing the value type, and will default to *null*.
- `default` is the default value, and will default to *true*.

```
protected array $options = [
    'name' => [
        'prompt' => 'What is your name?',
        'required' => true,
    ],
    'color' => [
        'prompt' => 'What is your favorite color?',
        'values' => [
            'red',
            'green',
            'blue',
        ],
    ],
    'confirmed' => [
        'prompt' => 'Do you want to continue?',
        'as' => 'boolean',
        'required' => true,
    ],
];

public function run(string $name, string|null $color, bool $confirmed): int;
```

If an option is marked as `required` and not provided as an argument, the *CommandRunner* will prompt for the value, otherwise the `default` value will be used.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance62

Regular maintenance activity

Popularity10

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

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 ~37 days

Recently: every ~52 days

Total

35

Last Release

238d ago

Major Versions

v2.0.3 → v3.02023-07-24

v3.0.4 → v4.02024-06-08

v4.0.5 → v5.02024-11-06

v5.0 → v6.02024-11-08

v6.3.4 → v7.02025-10-29

### Community

Maintainers

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

---

Top Contributors

[![elusivecodes](https://avatars.githubusercontent.com/u/18050480?v=4)](https://github.com/elusivecodes "elusivecodes (27 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[seld/cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

24726.4M22](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

13045.3M6.2k](/packages/illuminate-console)

PHPackages © 2026

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