yii2 用命令行操作web下的controller

来源:互联网 发布:php源码怎么本地测试 编辑:程序博客网 时间:2024/05/29 03:47

Console Runner

An extension for running console commands on background in Yii framework.

Installation

Add the following to require section of your composer.json:

"vova07/yii2-console-runner-extension": "*"

Then do composer install.

Usage

Imported class:

use vova07\console\ConsoleRunner;$cr = new ConsoleRunner(['file' => '@my/path/to/yii']);$cr->run('controller/action param1 param2 ...');

Application component:

// config.php...components [    'consoleRunner' => [        'class' => 'vova07\console\ConsoleRunner',        'file' => '@my/path/to/yii' // or an absolute path to console file    ]]...// some-file.phpYii::$app->consoleRunner->run('controller/action param1 param2 ...');
0 0