Home  >  Article  >  PHP Framework  >  How to execute cmd command on e disk yii

How to execute cmd command on e disk yii

尚
Original
2019-12-17 14:41:443226browse

How to execute cmd command on e disk yii

yii2.0 supports php command line operation.

The operation method is as follows:

There is a "yii" file under the yii root directory (not "yii.bat"), this file is the entry. Then there will be a "HelloController.php" controller file by default in the "commands" directory, which is a demo. Open this controller file, the source code is as follows (some comments are deleted):

As can be seen from the above, when running on the command line, the Controller under the console will be inherited; and generally the Controller in the "controllers" directory The controller will inherit the Controller under web.

The steps to execute the yii script in the php command line are:

1. Create a new script

Follow the "HelloController" command under the "commands" directory Create a new controller script file in the format of .php".

2. Execute the script on the command line

Type "php yii project location path/yii controller name/method name" on the command line, for example "php E:/wwwroot/yii2/ yii hello/index”

As shown below:

How to execute cmd command on e disk yii

or as shown below

How to execute cmd command on e disk yii

It should be noted that: PHP must set environment variables before it can be used in this way. If you want to know whether php has been added to the environment variable, please use the "php -v" command to check.

PHP Chinese website has a large number of free Yii introductory tutorials, everyone is welcome to learn!

The above is the detailed content of How to execute cmd command on e disk yii. 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