本文介绍了Kohana 3.1-系统未加载电子邮件模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a problem using Kohana 3.1. I add the old banks kohana-email module but the result is a error like this:

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

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

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

My application bootstrap.php file is like this:

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
    ));

如您所见,我尝试使用另一个电子邮件模块(mailer模块和shadowhand的电子邮件模块)相同的结果。

As you can see, I tried with another email modules (mailer module and shadowhand's email module) with the same result.

考虑到错误消息,我仅使用如下init.php文件创建了一个模块(名为testmod):

Thinking about the error message, I create a module (named testmod) only with a init.php file like this:

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

然后,在引导程序中添加testmod模块,我得到了有效。

then, adding the testmod module in bootstrap, I get the "It works".

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

So, if the another modules (like orm, auth, user) works right, why kohana-email, emailer and mailer don't work?

编辑:
我必须扩大解释:

I must to extend my explanation:

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

The kohana-email module is in MODPATH.'kohana-email', because doing a echo MODPATH; I can see the correct modules place.

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

My modules file-tree is like this:

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电子邮件模块进行了探查,但出现了同样的错误。

Yes, I probe it with Email::connect(); in the same bootstrap.php, after the Kohana::modules line, and is here where throws the ErrorException. And, yes, I probe it with the shadowhand email module, but I get the same Error.

因此,我再次提出了一个问题:

So, I re-ask the question:

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

Why kohana-email (and email, and mailer) module does not work? Or, why kohana can't locate the Email class?

推荐答案

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

The problem are the modules directory permissions as you can see here:

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(),
  )
);

感谢影子之手。

这篇关于Kohana 3.1-系统未加载电子邮件模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 07:28