Home> PHP Framework> YII> body text

How to execute cmd command on e disk yii

Release: 2019-12-17 14:41:44
Original
3312 people have browsed it

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):


        
Copy after login

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 freeYii 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!

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!