开发者

Kohana 3.1 - The system does not load email module

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 [ Fatal Error ]: Class 'Email' not found

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',   开发者_StackOverflow中文版  // 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
    ));

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

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

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

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

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

EDIT: I must to extend my explanation:

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

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:

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

Thanks to shadowhand.


I had a similar problem. On my localhost (OS Windows) all working fine, but on server (Ubuntu) I'm already get this error. I'm just renamed email.php to Email.php in modules/email/classes and everything was working.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜