1

コハナ3.1の使用に問題があります。古い銀行のkohana-emailモジュールを追加しましたが、結果は次のようなエラーになります。

ErrorException [致命的なエラー]:クラス'Eメール'が見つかりません

私のアプリケーションの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
    ));

ご覧のとおり、別の電子メールモジュール(メーラーモジュールとシャドウハンドの電子メールモジュール)を試してみたところ、同じ結果になりました。

エラーメッセージについて考えて、次のようなinit.phpファイルのみを使用してモジュール(testmodという名前)を作成します。

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

次に、ブートストラップにtestmodモジュールを追加すると、「動作します」というメッセージが表示されます。

では、他のモジュール(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がスローされます。そして、はい、シャドウハンドの電子メールモジュールでプローブしますが、同じエラーが発生します。

だから、私は質問を再質問します:

kohana-email(およびemail、mailer)モジュールが機能しないのはなぜですか?または、なぜkohanaがEメールクラスを見つけられないのですか?

4

2 に答える 2

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

shadowhandに感謝します。

于 2011-04-06T13:11:45.397 に答える
0

私も同様の問題を抱えていました。私のローカルホスト(OS Windows)ではすべて正常に動作していますが、サーバー(Ubuntu)ではすでにこのエラーが発生しています。名前がinに変更email.phpEmail.phpmodules/email/classes、すべてが機能していました。

于 2013-07-05T14:58:27.797 に答える