Yii source code-environment & Configuration

Source: Internet
Author: User
Yii source code-Environment & configuration environment

CookieValidationKey: a pure configuration item that is closely related to the local environment.

However, in some cases, cookieValidationKey requires O & M personnel to intervene, rather than automatically generating it randomly.

For example, when your application uses a distributed architecture to provide services and runs on multiple nodes at the same time. Some server load balancer policies randomly allocate two requests from the same user to different nodes for processing. If the cookieValidationKey of the two nodes is inconsistent, the user will receive a strange error message.

Configuration

A config map is used to configure an object and initialize or configure the properties of an object.

For

[    'class' => 'path\to\ClassName',    'propertyName' => 'propertyValue',    'on eventName' => $eventHandler,    'as behaviorName' => $behaviorConfig,]
  • The configuration items are organized in arrays.

  • The class array element indicates the complete class name of the object to be created.

  • The propertyName array element indicates that the initial value of the attribute specified as propertyName is $ propertyValue.

  • The on eventName array element binds $ eventHandler to the eventName event of the object.

  • The as behaviorName array element indicates to use $ behaviorConfig to create an action and inject it into the object. $ BehaviroConfig is also a configuration item;

  • Configuration items can be nested.

Configuration plays a role

Know from the portal,

$application = new yii\web\Application($config);

Load the configuration item and call the preInit () pre-initialization configuration of yii \ base \ Application.

There are two types of special configuration items that need to be noted, namely, the on * headers and the as * headers.

Yii processes these two types of configuration items in yii \ base \ Component ::__ set (). events and behaviors are supported only from Component.

For configuration items in the form of on event, Yii regards the configuration value as an event handler and binds it to the event. For configuration items in the form of as behavior, the configuration value is considered as a Behavior, which is injected into the current instance and named as behavior.

Reference

  1. Http://www.digpage.com/

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.