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. Run yii.bat hello/index --sex=male meng under cmd
hello/index: controller route
--sex=male: controller public properties
meng: parameters of the index action
3. Running result: