200mph/m-commander

该包已被废弃,不再维护。没有建议的替代包。

通过命令行执行您自己的模块的简单工具

1.1.5 2016-12-06 16:59 UTC

This package is not auto-updated.

Last update: 2020-01-24 16:03:39 UTC


README

通过命令行执行您自己的模块的简单工具

1.通过Composer安装(最佳选项,但也可以不使用Composer使用它)

"200mph/m-commander": "1.1.*"

2.创建您的命令行模块类,并从m-commander供应商扩展AbstractCliModule()

namespace cli\MyTest;

use m-commander\AbstractCliModule;

class TestMe() extends AbstractCliModule 
{

    /**
     * We have to create execute() method (abstraction requirements)
     *
     * @return void
    /*
    protected function execute()
    {

        $this->successOutput('Hello World' . PHP_EOL);

    }
}

3.运行您的模块

./vendor/bin/m-commander cli\\MyTest\\TestMe -v

您也可以使用半引号来避免双反斜杠的表示法。

./vendor/bin/m-commander 'cli\MyTest\TestMe' -v

如果命令需要在CRON或其他shell脚本中执行,建议使用上述表示法。

更多示例,请查看./examples文件夹

4.默认选项

-h --help 显示此页面 -v --verbose 详细模式 -w --write-output 将输出写入文件。例如: "./m-commander 'myNamespace\MyModule' -w /home/user/test.log" -l --lock 锁定模块进程。完成当前实例之前,不允许运行此相同模块的另一个实例。但是您可以执行另一个模块的脚本。