The content of this article is about yii2 console commands, which has certain reference value. Now I share it with everyone. Friends in need can refer to it
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 under cmd --sex=male meng
hello/index: Controller routing
--sex=male: Controller public attributes
meng: Parameters of index action
3. Running result:
Related recommendations:
Yii multi-application multi-module
Basic concepts of Yii2 configuration
The above is the detailed content of yii2 console commands. For more information, please follow other related articles on the PHP Chinese website!