【问题标题】:Kohana not loading custom module classKohana 没有加载自定义模块类
【发布时间】:2015-06-05 02:17:27
【问题描述】:

我已经在 Kohana 中创建了一个模块,但是当我尝试使用它时遇到了问题。当我尝试使用该类时,出现以下错误:

ErrorException [ Fatal Error ]: Class 'PopcornInteractor' not found

APPPATH/classes/model/movie.php [ 120 ]
118     public function getPopcorn($popcorn) {
119         $uid = null;
120         $pci = new PopcornInteractor();

bootstrap.php 文件具有以下模块配置

Kohana::modules(array(
  ...,
  'popcornmod' => MODPATH.'popcornmod'
));

当我调试 Kohana::modules() 时,我得到以下结构:

...
popcornmod : "\/var\/www\/html\/mywebsite.com\/modules\/popcornmod\/"

我的文件结构是:

modules                       
+                             
+-+popcornmod                 
   +                          
   +-+classes                 
   |  +                       
   |  +-+PopcornInteractor.php
   |                          
   +-+config                  
   |  +                       
   |  +-+popcornmod.php       
   |                          
   +-+init.php

PopcornInteractor.php 文件内容如下:

class PopcornInteractor {
    protected $config;
    function __construct() {
        $this->config = Kohana::$config->load('popcornmod')->as_array();
    }
}

最后,在错误显示时显示的包含文件消息上,它显示:

MODPATH/email/vendor/swiftmailer/lib/swift_required.php
MODPATH/email/vendor/swiftmailer/lib/classes/Swift.php
MODPATH/popcornmod/init.php
SYSPATH/classes/cookie.php
SYSPATH/classes/kohana/cookie.php

我尝试查找 PopcornInteractor.php,但它不在包含的文件中。

该模组在我的本地安装 (OS X) 中运行良好,但当我上传到服务器 (Linux) 时它无法运行。

有什么想法吗?

【问题讨论】:

    标签: php module kohana


    【解决方案1】:

    改了文件名,现在可以工作了,最终的结构是:

    modules                       
    +                             
    +-+popcornmod                 
       +                          
       +-+classes                 
       |  +                       
       |  +-+popcorninteractor.php <-- change: lower cases
       |                          
       +-+config                  
       |  +                       
       |  +-+popcornmod.php       
       |                          
       +-+init.php
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多