Kohana 3.1 - 系统不加载电子邮件模块

时间:2011-04-05 13:46:26

标签: php email kohana kohana-3 mailer

使用Kohana 3.1时遇到问题。我添加旧银行kohana-email模块,但结果是这样的错误:

ErrorException [致命错误]:未找到“电子邮件”类

我的应用程序bootstrap.php文件是这样的:

Kohana::modules(array(
    'user'      => MODPATH.'user',   // Useradmin module
    'auth'      => MODPATH.'auth',   // Basic authentication
    // 'cache'      => MODPATH.'cache',      // Caching with multiple backends
    // 'codebench'  => MODPATH.'codebench',  // Benchmarking tool
    'database'  => MODPATH.'database',   // Database access
    // 'image'      => MODPATH.'image',      // Image manipulation
    'orm'           => MODPATH.'orm',        // Object Relationship Mapping
    'kohana-email'  => MODPATH.'kohana-email',   // Kohana email module
    //'email'       => MODPATH.'email',     // Email module
    //'mailer'      => MODPATH.'mailer',        // Mailer module
    'pagination'    => MODPATH.'pagination', // Pagination module
    'testmod'   => MODPATH.'testmod',
    // 'unittest'   => MODPATH.'unittest',   // Unit testing
    // 'userguide'  => MODPATH.'userguide',  // User guide and API documentation
    ));

正如您所看到的,我尝试使用其他电子邮件模块(邮件程序模块和shadowhand的电子邮件模块),结果相同。

考虑到错误消息,我只使用这样的init.php文件创建一个模块(名为testmod):

<?php
  die('It works');
?>

然后,在bootstrap中添加testmod模块,我得到“It works”。

那么,如果其他模块(如orm,auth,user)工作正常,为什么kohana-email,emailer和mailer不起作用?

编辑: 我必须扩展我的解释:

kohana-email模块位于MODPATH.'kohana-email',因为执行echo MODPATH;我可以看到正确的模块位置。

我的模块文件树是这样的:

modules (as echo MODPATH says)
  |
  +-- user     (files from user module, this module works right)
  |
  +-- auth     (files from auth module, this module works right)
  |
  +-- testmod     (init.php file from testmod, this module works right)
  |
  +-- kohana-email
  !     |
  :     +-- classes
  :     |     |
  :     |     +-- email.php    <--- The Email class is here!
  :     |
  :     +-- config
  :     |     |
  :     |     +-- email.php
  :     |
  :     +-- vendor
  ·           |
  ·           +-- swift
                    !
                    :     (files from swift)
                    ·

是的,我在Email::connect();行之后的同一个bootstrap.php中用Kohana::modules探测它,并且在这里抛出ErrorException。而且,是的,我使用shadowhand电子邮件模块进行探测,但我得到了相同的错误。

所以,我再问一下这个问题:

为什么kohana-email(以及电子邮件和邮件程序)模块不起作用?或者,为什么kohana找不到电子邮件类?

2 个答案:

答案 0 :(得分:1)

问题是模块目录权限,您可以在此处看到:

echo Debug::vars('What does this mean? Look at '.__FILE__.' line '.__LINE__,
/**
* PROTIP: Wrapping several variables in an array() prevents tailing
* commas "," causing exceptions.
*
* Each step below was added after the last step returned the expected result.
*/
array(
  // The path to the module
  $p = MODPATH.'kohana-email',
  // should be a directory
  is_dir($p),
  // The path to "classes/"
  $c = $p.DIRECTORY_SEPARATOR.'classes',
  // should also be directory
  is_dir($c),
  // This doesn't seem right... the last call said it wasn't a directory
  shell_exec('ls -al '.escapeshellarg($c)),
  // That failed too? Wait a second...
  shell_exec('ls -al '.escapeshellarg(MODPATH)),
  // It looks like the the module directory is not readable!
  is_readable($p),
  is_readable($c),
  // Both returned FALSE! We need to correct the permissions!
  // I ran the following commands in my console the project root:
  // $ find modules/ -type d -exec chmod 0755 {} \;
  // $ find modules/ -type f -exec chmod a+r {} \;
  // All permissions should be fixed now, all previous debugging was
  // returning the proper values, so attempt to load the class
  class_exists('Email'),
  // Hooray!
  Email::connect(),
  )
);

感谢影子。

答案 1 :(得分:0)

我有类似的问题。在我的localhost(OS Windows)上工作正常,但在服务器(Ubuntu)上我已经收到此错误。 我刚刚在email.php中将Email.php重命名为modules/email/classes,一切正常。

相关问题