PHPackages                             finnbar/commander - 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. finnbar/commander

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

finnbar/commander
=================

04PHP

Since Aug 13Pushed 9mo agoCompare

[ Source](https://github.com/fmccl/commander)[ Packagist](https://packagist.org/packages/finnbar/commander)[ RSS](/packages/finnbar-commander/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Command parsing library for PocketMine-MP
=========================================

[](#command-parsing-library-for-pocketmine-mp)

Commander uses reflection to allow commands to be written more declaritively.

Example
-------

[](#example)

```
class Main extends PluginBase
{
    public function onEnable(): void
    {
        $commander = new Commander("myfallbackprefix", $this);

        $commander->registerCommand(MyGiveCommand::class);
    }
}

class MyGiveCommand implements CommanderCommand
{
    public function __construct(private CommandContext $ctx) {}

    public static function getDescription(): string
    {
        return "This is a test command";
    }

    public static function getPermissions(): array
    {
        return [
            "myplugin.command.mygivecommand",
        ];
    }

    // Command parameters are parsed depending on their types, in the order you define them.
    // In this case, the usage message, which will be generated automatically will be:
    // /mygivecommand   [count: int]
    public function execute(Player $player, Item $item, int $count = 1): void {
        $i = $item->setCount($count);
        $player->getInventory()->addItem($i);
    }

    public static function getName(): string
    {
        return "mygivecommand";
    }
}
```

As explained in the comment above, parsed depending on their types, in the order you define them. As a bonus, this enables us to add auto-completion, like a vanilla command! Players will be able to tab-complete player and item names as they would with vanilla commands

Documentation
-------------

[](#documentation)

### TrailingString

[](#trailingstring)

The `TrailingString` class should be used as a parameter type when you want to allow spaces in a string - for example in the /say command. Since it allows spaces, it must be the last parameter, otherwise parameters after it will not be usable.

### Automatic UI

[](#automatic-ui)

Though this is primarily meant for internal tools e.g. config editing, there can be an automatically generated form UI. Just add `implements UICommand`. Then, when the command is used with no arguments, the user will be asked to provide them in a form. UICommand is just a marker interface, it doesn't have any functions that you need to implement.

TODO:

- Track if UI is being used in CommandContext
- Add displayText function that will send a message when used from command mode and send an empty MenuForm when used from UI mode
- Item picker using InvMenu
- Player picker MenuForm
- Escape = Go back
- Easy way to add menu reopening if the menu is closed
- Easy way to add menuforms for enums (soft and hard) and tbh enums need to be easier in commands too. I'll probably do this with parameter attributes.

### Subcommand

[](#subcommand)

Subcommands are supported but I haven't really finalized the way they're going to work. There's one in the Main.php file - I will write some documentation for them once I've finished with them.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance41

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![fmccl](https://avatars.githubusercontent.com/u/170548436?v=4)](https://github.com/fmccl "fmccl (7 commits)")

### Embed Badge

![Health badge](/badges/finnbar-commander/health.svg)

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

###  Alternatives

[wp-cli/wp-cli

WP-CLI framework

5.1k17.2M320](/packages/wp-cli-wp-cli)[consolidation/annotated-command

Initialize Symfony Console commands from annotated command class methods.

22569.8M19](/packages/consolidation-annotated-command)[seld/cli-prompt

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

24725.8M17](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[php-tui/php-tui

Comprehensive TUI library heavily influenced by Ratatui

589747.0k6](/packages/php-tui-php-tui)[codedungeon/php-cli-colors

Liven up you PHP Console Apps with standard colors

10210.1M26](/packages/codedungeon-php-cli-colors)

PHPackages © 2026

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