Introduction to PHP Yii Open source Framework (iii) Summary of related configuration of Yii

Source: Internet
Author: User

The following is a summary of the related configuration of Yii:

Configuration in 1,/protected/config/main.php:

1) Modify the default controller, download the source code default controler for Sitecontroller:

In protected/config/main.php, the value of the modifier key Defaultcontroller is the specified controller, and the default action must be specified in the controller. Use Defaultcontroller/defaultaction to respond when the request is not explicitly intended.

' Defaultcontroller ' => ' main ',

After setting up access to the site root path, you can jump to the corresponding Controller:MainController.php

Download the source code defaults to site, is specified in the yiilite.php file, in the example to jump to sitecontroller.php

2) Modify the default login action:

When the unknown login page, when not logged in to access the page that needs to be logged in, Yii jumps to the default login action and the default action is Site/login, which can also be customized in the main.php or module configuration file

' Components ' =>array (

' User ' =>array (

' Allowautologin ' =>true,

' Loginurl ' =>array (' main/login.html '),

),

...

3 The definition of database connection:

' DB ' =>array (

' connectionString ' => ' Mysql:host=localhost;dbname=db_schema ',

' Emulateprepare ' => true,

' username ' => ' root ',

' Password ' => ' 123 ',

' CharSet ' => ' UTF8 ',

' Tableprefix ' => ' zz_ ',

),

4 The default error action definition, which is invoked when an error occurs:

' ErrorHandler ' =>array (

' ErrorAction ' => ' main/error ',

),

5) Adding modules:

' Modules ' =>array (

...,//other modules

' Admin ',

),

You can access it by path after adding it:

Http://127.0.0.1:8080/zuizen/index.php?r=admin/default

Or:

http://127.0.0.1:8080/zuizen/admin/If the access path is modified by the previous section

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.