huynhtuvinh87/yii2-console-runner

运行 Yii 控制台

安装: 2

依赖: 0

建议者: 0

安全: 0

星星: 0

关注者: 1

分支: 0

开放问题: 0

类型:yii2-extension

dev-master 2018-09-15 03:51 UTC

This package is not auto-updated.

Last update: 2024-09-23 15:05:17 UTC


README

这是一个用于在 yii2 网络应用程序中运行控制台命令的组件

安装

安装此扩展的首选方式是通过 composer

安装,可以运行

$ composer require huynhtuvinh87/yii2-console-runner "*"

或者将以下内容添加到你的 composer.json 文件的 require 部分。

"huynhtuvinh87/yii2-console-runner": "*"

使用方法

你可以通过导入类文件使用 yii2-console-runner

use huynhtuvinh87\console\Runner;
$output = '';
$runner = new Runner();
$runner->run('controller/action param1 param2 ...', $output);
echo $output; //prints the command output

或者像使用应用组件一样使用它

//you config file
'components' => [
    'consoleRunner' => [
        'class' => 'toriphes\console\Runner'
    ]
]
//some application file
$output = '';
Yii::$app->consoleRunner->run('controller/action param1 param2 ...', $output);
echo $output; //prints the command output