Two primary questions about the yii framework

Source: Internet
Author: User
1. For example, how is the content displayed by frontedwebindex. php determined (index itself is not a page display) 2. For an app, it is often used to return to the home page. Where is the gethomeurl set? 1. For example, how to determine the content displayed by fronted/web/index. php (index itself is not displayed on the page)
2. For an app, it is often used to return to the home page. Where is the gethomeurl set?

Reply content:

1. For example, how to determine the content displayed by fronted/web/index. php (index itself is not displayed on the page)
2. For an app, it is often used to return to the home page. Where is the gethomeurl set?

I wanted to analyze the source code for a limited time.
Directly go to common/config/main. php

Return [// The default route goHome of the application will jump to 'defaultroute '=> 'controller/action' by default. Another way is to configure the urlManeger component 'components' => ['urlmanager' => [// This baseUrl will eventually decide the path of homeUrl, which is equivalent to specifying a domain name for the current application, and then the route of the real application jumps to 'baseurl' => 'HTTP: // www.test.com ', 'class' => 'yii \ web \ urlmanager', 'enableprettyurl' => true, 'showscriptname' => false, // 'suffix '=> 'path',],]

  1. Structure-controllers
  2. $controllerObj->redirect(); $controllerObj->goHome();Usage in the example. For more information, see api

  1. In Yii, the default url should be like this:Http: // domain name/index. php? R = controllerName/actionName & Parameter 1 = value 1 & Parameter 2 = value 2
    For fronted/web/index. php, visual testing, frontend should be the website front-end, that is, there is a web directory under the frontend directory, and the web directory contains the index. PHP file, which is the only front-end entry.

  2. Back to the home page is not under control$this->redirect('/');Is the translated URL http: // domain name?

PS: add the first point. The web directory should be the root directory of the web server. For example, if you want to access the actionTest () method under fooController, your url should be written as follows: http: // domain name/index. php? R = foo/test

The first problem is not very clear, and the second problem is that the returned home page can be used in the controller.$this->goHome();

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.