Yii custom model path _ PHP Tutorial

Source: Internet
Author: User
Yii custom model path. For example, there are two Yii projects, test1 and test2. In test1, there is already a model. test2 calls the model in test1 directly. In fact, it adds an alias and modifies the configuration. for example, there are two Yii projects, test1 and test2.
The model already exists in test1. test2 calls the model in test1 directly. In fact, add an alias and modify the configuration.

First, add:

Yii: setPathOfAlias ('pubmodels', dirname (_ FILE _). '/../test1/protected/models ');

Set the path of your project as needed.

Open the configuration file main. php and add

'Import' => array ('application. models. * ', 'pubmodels. *', // This is the test1 model 'application. components .*',)

If you do not need the model of the current project, comment out 'application. models.

In this way, you can share a model.
If you use giix, you can also use this method to call the same extension, language pack, and so on. you can set aliases and share the call.

The policyii project is test1 and test2. The model already exists in test1. test2 calls the model in test1 directly. In fact, it adds an alias and modifies the configuration...

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.