这篇文章介绍的内容是关于yii2 控制台命令,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下
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. cmd下运行 yii.bat hello/index --sex=男 meng
hello/index:控制器路由
--sex=男: 控制器公共属性
meng: index动作的参数
3. 运行结果:

相关推荐:










