PHPackages                             easyswoole/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. [Framework](/categories/framework)
4. /
5. easyswoole/command

ActiveLibrary[Framework](/categories/framework)

easyswoole/command
==================

An efficient swoole framework

2.0.3(1mo ago)094.6k↓38.5%18Apache-2.0PHPPHP &gt;=8.1

Since May 22Pushed 1mo agoCompare

[ Source](https://github.com/easy-swoole/command)[ Packagist](https://packagist.org/packages/easyswoole/command)[ Docs](https://www.easyswoole.com/)[ RSS](/packages/easyswoole-command/feed)WikiDiscussions 2.x Synced 2w ago

READMEChangelog (10)Dependencies (3)Versions (15)Used By (8)

Command
=======

[](#command)

### Example

[](#example)

```
use EasySwoole\Command\AbstractInterface\AbstractCommand;
use EasySwoole\Command\Bean\Action;
use EasySwoole\Command\Bean\Caller;
use EasySwoole\Command\Bean\ExecStatusEnum;
use EasySwoole\Command\Bean\Option;
use EasySwoole\Command\Bean\Param;
use EasySwoole\Command\Bean\Result;
use EasySwoole\Command\Manager;
use EasySwoole\Command\Utility;

class TestCommand extends AbstractCommand{
    function name(): string
    {
        return 'testCmdss';
    }

    function description(): string
    {
        return 'test command desc';
    }

    protected function init(): void
    {
        $actionA = new Action('actionA','actionA description');

        $actionA->addOption(new Option(
            name:'opt1',
            description: "opt1 description"
        ));
        $actionA->addParam(new class('num1',"num1 desc") extends Param{
            public static function validate(mixed $value,Caller $caller): bool|string
            {
                if($value < 5){
//                    return 'num1 must be greater or equal to 5';
                }
                return true;
            }
        });
        $actionA->addOption(new Option('opt2'));
        $actionA->setCallback([$this, 'actionA']);
        $this->registerAction($actionA);

        $actionB = new class('actionB','action b desc easyswoole ') extends Action{
            protected function init(): void
            {
                $this->setCallback(function (Caller $caller,Result $result) {
                    $result->result = $caller->commandLine->getParam('num1') + $caller->commandLine->getParam('num2');
                });
                $this->addParam(new class('num1',"num1 desc") extends Param{
                    public static function validate(mixed $value,Caller $caller): bool|string
                    {
                        if($value < 5){
                            return 'num1 must be greater or equal to 5';
                        }
                        return true;
                    }
                });

                $this->addParam(new class('num2') extends Param{
                    public static function validate(mixed $value,Caller $caller): bool|string
                    {
                        if($value > 5){
                            return 'num2 must be small or equal to 5';
                        }
                        return true;
                    }
                });
            }
        };

        $this->registerAction($actionB);

    }

    function actionA(Caller $caller, Result $result)
    {
        $num1 = $caller->commandLine->getOption('opt1');
        if(empty($num1)){
            $result->msg = 'option opt1 miss , eg: num1=9501';
            $result->status = ExecStatusEnum::COMMAND_ACTION_EXEC_FAIL;
            return;
        }
        $num2 = intval($caller->commandLine->getOption('opt2'));
        $result->result = $num1 + $num2;
    }

}

class Fly extends AbstractCommand{
    function name(): string
    {
        return 'fly';
    }

    function description(): string
    {
        return 'fly command description';
    }
}

$fly = new Fly();
$actionA = new Action('actionA');

$actionA->addOption(new Option('opt1',"opt1 description"));

$actionA->addOption(new class ('opt2') extends Option
{
    public static function validate(mixed $value,Caller $caller): bool|string{
        if($value < 5){
            return 'opt1 must be greater or equal to 5';
        }
        return true;
    }
});

$actionA->setCallback(function (Caller $caller,Result $result) {
    $result->result = time() + $caller->commandLine->getOption('opt2');
    $result->msg = "your opt1 is ".$caller->commandLine->getOption('opt2');
});

$fly->registerDefaultAction($actionA);
$fly->registerAction($actionA);

$manager = new Manager();
$manager->addCommand(new TestCommand());
$manager->addCommand($fly);

$commandLine = Utility::parseArgv($argv);
array_shift($commandLine->unknows);
$command = array_shift($commandLine->unknows);
$action = array_shift($commandLine->unknows);
$call = new Caller($command,$action,$commandLine);
$ret = $manager->exec($call);

if($ret->status == ExecStatusEnum::OK){
    if(!empty($ret->msg)){
        echo "{$ret->msg}\n";
    }
}else{
    $ret = $manager->result2HelpMsg($call,$ret);
    echo $ret;
}
```

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance94

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 54.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 ~173 days

Recently: every ~535 days

Total

14

Last Release

31d ago

Major Versions

1.1.7 → 2.0.12026-07-15

PHP version history (2 changes)1.0.0PHP &gt;=7.1.0

2.0.1PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/45c234d5f129ea570e630425636299127647534f0c2cbb073555e2c45d403d6f?d=identicon)[kiss291323003](/maintainers/kiss291323003)

---

Top Contributors

[![kiss291323003](https://avatars.githubusercontent.com/u/24490609?v=4)](https://github.com/kiss291323003 "kiss291323003 (34 commits)")[![Player626](https://avatars.githubusercontent.com/u/44792981?v=4)](https://github.com/Player626 "Player626 (21 commits)")[![Heelie](https://avatars.githubusercontent.com/u/27876556?v=4)](https://github.com/Heelie "Heelie (7 commits)")

---

Tags

asyncframeworkswooleeasyswoole

### Embed Badge

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

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

###  Alternatives

[easyswoole/easyswoole

An efficient swoole framework

4.8k191.4k57](/packages/easyswoole-easyswoole)[easyswoole/orm

php stander lib

3291.5k29](/packages/easyswoole-orm)[easyswoole/kafka

An efficient swoole framework

4211.6k](/packages/easyswoole-kafka)[easyswoole/fast-cache

An efficient swoole framework

1030.8k4](/packages/easyswoole-fast-cache)[easyswoole/actor

easyswoole component

1410.4k](/packages/easyswoole-actor)[easyswoole/words-match

An efficient swoole framework

171.7k10](/packages/easyswoole-words-match)

PHPackages © 2026

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