1. HelloController.php
<?php
namespace console\controllers;
use Yii;
use yii\console\Controller;
class HelloController extends Controller{
public $sex;
public function options( $actionID ){
return ['sex'];
}
public function actionIndex($name){
echo "Hello ". $name;
echo "<br>";
echo $this->sex;
return 0;
}
}
2. 运行
a. cmd下运行 yii.bat hello/index --sex=男 meng
hello/index:控制器路由
--sex=男: 控制器公共属性
meng: index动作的参数
b. linux 下运行:/usr/local/php/bin/php /mnt/www/mxhy/yii import/admin-upload
3. 运行结果: