filsh / yii2-runner
运行不同对象或函数的组件
dev-master
2015-05-17 21:54 UTC
Requires
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-08-29 04:03:26 UTC
README
安装
建议您通过 composer 安装 Gearman 库 (点击访问)。为此,请将以下行添加到您的 composer.json
文件中。
{ "require": { "filsh/yii2-runner": "dev-master" } }
示例
// example runner class Example extends \filsh\yii2\runner\BaseRunner { public $fooValue; public $barValue; public function run() { echo 'example runner with param: ' . json_encode([$this->fooValue, $this->barValue]); } } // configure component 'components' => [ 'runner' => [ 'class' => 'filsh\yii2\runner\RunnerComponent', 'runners' => [ 'example' => [ 'class' => Example::className(), 'fooValue' => 'foo' ] ] ] ], // run examples $this->runner->run('example', ['barValue' => 'bar']); // example runner with param: ["foo","bar"] $this->runner->run(function(array $params) { echo 'inline runner with params: ' . json_encode($params); }, ['fooValue' => 'foo']); // inline runner with params: {"fooValue":"foo"}