Yii导入功能 [英] Yii import functionality

查看:110
本文介绍了Yii导入功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的主配置中,我有:

In my main config i have:

'import' => array(
'application.models.*',
'application.components.*',

我在某处读到Yii import只在需要时才调用相关的类。
想知道它是否属实,如果一次导入所有文件夹是Yii的好习惯。
谢谢,
Danny

I read somewhere that Yii import only calls the relevant class when needed. Wanted to know if it's true and if importing all the folder at once is good practice in Yii. Thanks, Danny

推荐答案

在导入调用中,当你传入像'application.models。*'这样的文件夹时, Yii呢,它添加了php include_path的路径,这样当你调用该文件夹中包含的类时,如果Yii自动加载器失败,php会在include路径中查找该类,那就快了。

In the import call, when you pass in a folder like 'application.models.*', what Yii does, its add that path to the php include_path, so that when you call a class contained in that folder, if the Yii autoloader fails php looks for that class in the include path, thats fast.

如果你包含一个像'application.models.FormModel'这样的文件,那么Yii自动加载器就会知道它,并且只在deman上加载这个类。

If you include a file like 'application.models.FormModel', then Yii autoloader is aware of it and also loads the class on deman only.

您可以在Yii指南中找到更多信息:导入课程

you can find more information on the Yii guide: importing classes

这篇关于Yii导入功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆