Home > Backend Development > PHP Tutorial > Yii custom model path_PHP tutorial

Yii custom model path_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:29:20
Original
916 people have browsed it

For example, there are two Yii projects, test1 and test2.
In test1, there is already a model. Test2 directly calls the model in test1. In fact, just add an alias and then modify the configuration.

First add in the index.php entry file require_once($yii); followed by:

Yii::setPathOfAlias(<span>'pubModels'</span>, <span>dirname</span>(<span>__FILE__</span>) . <span>'/../test1/protected/models'</span>);
Copy after login

Just set your project path according to the actual situation.

Then open the configuration file main.php and add

in import
<span>'import'</span>=><span>array</span><span>(
    </span><span>'application.models.*'</span>,
    <span>'pubModels.*'</span>, <span>//</span><span> 这个就是 test1 的模型</span>
    <span>'application.components.*'</span>,<span>
)</span>
Copy after login

If you don’t need the model of the current project, just comment out 'application.models.*'.

This way you can share a model.
If you use giix, you can also use this method to call the same one. Extensions, language packs, etc. can set aliases and then share the call.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/777155.htmlTechArticleFor example, there are two Yii projects, namely test1 and test2. In test1, there is already a model. Test2 directly calls the model in test1. In fact, add an alias and then modify the configuration...
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template