Kohana 3.1 - Система не загружает почтовый модуль - PullRequest
1 голос
/ 05 апреля 2011

У меня проблема с использованием Kohana 3.1.Я добавляю старый модуль kohana-email для банков, но в результате получается ошибка, подобная этой:

ErrorException [Fatal Error]: класс 'Email' не найден

Файл моего приложения 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) с тем же результатом.

Думая о сообщении об ошибке, я создаюмодуль (с именем testmod) только с файлом init.php, подобным следующему:

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

, затем, добавив модуль testmod в bootstrap, я получаю «Это работает».

Итак, еслидругие модули (например, orm, auth, user) работают правильно, почему не работают kohana-email, e-mail и e-mail?

РЕДАКТИРОВАТЬ: я должен расширить свое объяснение:

Кохана-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?

Ответы [ 2 ]

1 голос
/ 06 апреля 2011

Проблема в разрешениях каталога модулей, как вы можете видеть здесь:

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

Благодаря shadowhand.

0 голосов
/ 05 июля 2013

У меня была похожая проблема. На моем локальном хосте (ОС Windows) все работает нормально, но на сервере (Ubuntu) я уже получаю эту ошибку. Я просто переименовал email.php в Email.php в modules/email/classes и все работало.

...