dongsu4345 2014-07-21 18:02
浏览 62

打开失败'''

Hi I am working in kohana 3.3.1 . Now I am stuck with an error while i am trying to send a plain text email. The exact error is given below

Fatal error: main() [function.require]: Failed opening required '' (include_path='.:/usr/local/altphp/lib/php:/home/gettrsm3/public_html/web/application/../Utilities:/home/gettrsm3/public_html/web/application/../Utilities/PHPUnit') in /home/gettrsm3/public_html/web/modules/Email/classes/Kohana/Email.php on line 449

Email.php Code(line 448-450)

// Load Swiftmailer
require Kohana::find_file('vendor/swiftmailer', 'lib/swift_required');

function swiftmailer_configurator() {...}

But under swiftmailer directory there is lib/swift_required.php file. anyone has any idea?

  • 写回答

1条回答 默认 最新

  • dtz63853 2014-07-25 15:05
    关注

    Kohana::find_file is specifically designed to look for files under the Kohana "Cascading Filesystem" structure. In general, this applies to files that are part of your Kohana application itself. It should not be used for a vendor directory where you always already know exactly what the path to the file will be.

    Instead, you should do this:

    require APPPATH . 'vendor/swiftmailer/lib/swift_required.php';
    

    Or, if the vendor stuff is in a module:

    require MODPATH . 'MODULE_NAME/vendor/swiftmailer/lib/swift_required.php';
    

    To make the second option here a little more flexible, you can define a new constant in your module's init.php like this:

    define('MODPATH_EMAIL', realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR);
    

    Then you can use this line:

    require MODPATH_EMAIL . 'vendor/swiftmailer/lib/swift_required.php';
    

    However, the last (and best alternative) is to use autoloading. If you have installed Swiftmailer in your vendor directory using Composer, then you can just do this:

    require 'vendor/autoload.php'; // Prefix this with anything else as necessary.
    
    评论

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)