Yii framework development tutorial (1) configure the environment and the first application helloworld

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.