weixin_33704234 2015-12-13 11:46 采纳率: 0%
浏览 17

Zend_Translate在Ajax调用中

I'm currently in the process of localizing a project with Zend_Translate. When trying to use the adapter in a php-file requested by an ajax call, I get the following error message(s):

Warning: require_once(Zend/Exception.php): failed to open stream:
File or Folder not found in
/my/include/path/Zend/Translate/Exception.php on
line 26

Fatal error: require_once(): Failed opening required
'Zend/Exception.php' (include_path='my/include/path') in
/my/include/path/Zend/Translate/Exception.php on
line 26

Thus, it seems to be a relative path problem. I'm particular confused about the 'require_once(Zend/Exception.php)' error since in the Zend main folder there is no such file -- however, as said before, non-ajax calls work just fine.

I tried to use if-statements to check from where the file's calling and adjust the include_path accordingly. This at least allowed the following lines to work both in ajax and non-ajax calls.

require(get_include_path().'/Zend/Translate.php');

Zend_Loader::loadClass('Zend_Translate');

However the above mentioned errors persist.

Zend is loaded from within a wrapper class. Here's the path structure:

class/                   class files, including a Zend wrapper class
js/                      js-files
js/ajax/                 php-files
vendor/Zend/...          Zend_Translate files

Let me know if more information is helpful.

  • 写回答

1条回答 默认 最新

  • weixin_33722405 2015-12-14 05:33
    关注

    Add the following lines before starting to use Zend Translate as an independent component

    set_include_path(implode(PATH_SEPARATOR, array(
        realpath('path/to/zend/library'),
        get_include_path(),
    )));
    
         require_once 'Zend/Loader/Autoloader.php';
    
            $autoloader = Zend_Loader_Autoloader::getInstance();
    

    Where

    path/to/zend/library

    is Zend Framework 1 library folder inside which Zend directory is present.

    评论

报告相同问题?

悬赏问题

  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号