Home  >  Article  >  Backend Development  >  Yii2 console commands

Yii2 console commands

不言
不言Original
2018-04-17 14:25:061782browse

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 [&#39;sex&#39;];
    }

    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 framework details

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:yii2 console commandsNext article:yii2 console commands