Preparations:
My development environment is Apache + MySQL + PHP in windows.
The editor does not know which one to use. use Dreamweaver for the moment.
The root directory of my own http: // localhost/is E:/website/localhost/
Yii is https://github.com/yiisoft/yii2/releases/download/2.0.0/yii-basic-app-2.0.0.tgz
Spare: http://download.csdn.net/detail/u012314976/8080883
Decompress the downloaded package to the root directory of the website.
Visit http: // localhost/basic/requirements. php to check whether your environment meets the requirements of yii.
Set cookievalidationkey. I set "zhyoulun ".
Access URL http: // localhost/basic/web/verify if everything is ready
Start writing helloworld
Step 1: Create the zhyouluncontroller. php file in the controllers folder.
<? Phpnamespace app \ controllers; Use yii \ filters \ accesscontrol; Use yii \ WEB \ Controller; Use yii \ filters \ verbfilter; // The class name zhyouluncontroller must correspond to the class zhyouluncontroller extends controller {public function actionhelloworld () {return $ this-> render ('helloworld ');}}
Step 2: Create the zhyoulun folder in the Views folder. This must correspond to "zhyoulun" in zhyouluncontroller. php.
Step 3: Create helloworld in views/zhyoulun. PHP file, which must correspond to "helloworld" and "helloworld" in "Action helloworld ()" and "return $ this-> render ('helloworld');" helloworld "in the zhyouluncontroller class.
<?phpecho 'hello world!';?>
Step 4: Visit the URL http: // localhost/basic/web/index. php? R = zhyoulun/helloworld
A more pure Display Method
Change return $ this-> render ('helloworld'); to return $ this-> renderpartial ('helloworld ');
Reference: http://www.yiichina.com/guide/2/start-hello
Reprinted please indicate the source: http://blog.csdn.net/zhyoulun/article/details/40453559
Yii framework development tutorial (1) configure the environment and the first application helloworld