简体   繁体   English

如何安装yii扩展程序,使其可用于整个Web应用程序?

[英]How can I install a yii extension, making it available to my whole web application?

Recently I decided to study php and I discovered yii framework. 最近,我决定学习php,并发现了yii框架。 At first glance it seemed very easy to work with it but now I am struggling to configure my web application for installing an extension to work with Enums. 乍一看,使用它似乎很容易,但是现在我正在努力配置Web应用程序以安装可与Enums一起使用的扩展程序。 I downloaded this extension from their web site and I put it within extensions folder. 我从他们的网站上下载了此扩展程序,并将其放在扩展程序文件夹中。 The issue is that I am not able to call the subclasses that I created in my code. 问题是我无法调用在代码中创建的子类。 I created a few classes that extend from this superclass (extension). 我创建了一些从该超类扩展的类(扩展)。

Which configuration I must do to make this extension class, available to my web application code? 为了使此扩展类可用于我的Web应用程序代码,我必须执行哪种配置?

As I said I just put that extension class in my extensions folder and I am just instantiating them, inside controller's methods. 就像我说的那样,我只是将该扩展类放在我的扩展文件夹中,而我只是在控制器的方法中实例化它们。 When I run the code I see the same error message no matter any configuration I make: 无论执行什么配置,运行代码时我都会看到相同的错误消息:

include (xxx.php): failed to open stream: No such file or directory 包括(xxx.php):无法打开流:没有这样的文件或目录

If anyone does want to know more about this extension this is the page that shows some information about that. 如果有人想进一步了解此扩展程序,则此页面显示有关此扩展程序的一些信息。

http://www.yiiframework.com/extension/enum/ http://www.yiiframework.com/extension/enum/

in config/main.php you should add your extension details in the components array, something like: config/main.php您应该在components数组中添加扩展详细信息,例如:

    return array(
        // 'preload'=>array('xyz',...),
        'components'=>array(
            'xyz'=>array(
                'class'=>'ext.xyz.XyzClass',
                'property1'=>'value1',
                'property2'=>'value2',
            ),
            // other component configurations
        ),

);

where xyz is an extension 其中xyz是扩展

or just put it in the extensions folder and import it by Yii::import('application.extensions.extensionname.*'); 或者只是将其放在扩展文件夹中,并通过Yii::import('application.extensions.extensionname.*');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM