Home > Backend Development > PHP Tutorial > Yii2 console commands

Yii2 console commands

不言
Release: 2023-03-24 08:18:02
Original
1853 people have browsed it

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;
    }


}
Copy after login


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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template