Management, deployment, and use of Assets resources in the Yii Framework

Source: Internet
Author: User
Management, deployment, and use of Assets resources in the Yii Framework

Assets (js, css, images, etc.) are generally released in the following ways, which must be used flexibly in practice:

1. save a single file directly under the Web Directory (for example, put pager.css in the css directory separately ). Advantages: high efficiency and relatively independent. Disadvantages: if the project is large and there may be many resource files, the management and usage of the project will be complicated. Reuse is also relatively complex. pay special attention to the storage location and corresponding URL of resource files when reusing them.

2. Save the code segment with it in the file under the Web Directory (for example, place pager's CSS in a main.css file and stay with other CSS files ). Advantages: high efficiency. Disadvantage: if the project is large, the resource file may be complex and difficult to maintain. In addition, reuse is more complex because the corresponding resource code snippets need to be extracted.

3. put the php code together and publish (copy) the php code to the web Directory through assetManager when calling the php code. Advantages: Easy to reuse (for example, if you use the yii built-in CLinkPager, you do not need to consider how to place its js/css ). Disadvantage: low efficiency.

Generally, if your code is not intended to be reused in other projects, consider 1 or 2. Method 2 is applicable to small projects. Method 3 is mainly used for components you want to reuse, such as google map.

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.