简体   繁体   English

在PHP应用程序中包括zend模块

[英]including zend module in php application

I'm using Zend to include Google agenda in my php application (I use CodeIgniter as framework). 我正在使用Zend在我的PHP应用程序中包含Google议程(我使用CodeIgniter作为框架)。 But I have many warnings like : 但是我有很多警告,例如:

Message: include_once(Zend/Gdata.php): failed to open stream: No such file or directory.

There is my directory list : 这是我的目录列表:

--dir1
       -- Zend
           -- Loader.php

/var/www/my_app
  --controllers
     -- calendar.php

In calendar.php, this is my path configuration 在calendar.php中,这是我的路径配置

 require_once '../Zend/Loader.php';

The error occurs when these lines are executed : 当执行这些行时,将发生错误:

require_once '.../Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');

and especially it comes from the function which loads files in Loader.php : 特别是它来自在Loader.php中加载文件的功能:

  public static function loadFile($filename, $dirs = null, $once = false)
        { ........    
include_once $filename;  }            

I tried to remove Zend so it can be in the same directory as the controller as suggested in many answers to this problem but it still not work. 我试图删除Zend,以便可以将它放在与控制器相同的目录中,此问题的许多答案中都建议使用它,但它仍然无法正常工作。 Could anyone help me please ? 有人可以帮我吗?

Thanks 谢谢

To include files in PHP you have 2 options : 要在PHP中包含文件,您有2个选择:

1) Define the full server path, like this : 1)定义完整的服务器路径,如下所示:

/home/project/dir1/Zend/Gdata.php

2) Define the path from the file that is executed by apache/something else, like this with the dir1 : 2)定义由apache /其他方式执行的文件的路径,例如dir1:

dir1/Zend/Gdata.php

In a Zend project you can do this to be sure it will work : 在Zend项目中,您可以执行以下操作以确保其有效:

include_once(APPLICATION_PATH."/../dir1/Zend/Gdata.php")

I finally found the solution. 我终于找到了解决方案。 Open the php.ini file and find the include_path line. 打开php.ini文件并找到include_path行。 . Add to the include_path the directory that you placed the ZendGdata directory in. /your/directory/ZendGdata/library . 将您将ZendGdata目录放在其中的目录添加到include_path中。/ your / directory / ZendGdata / library。 Save and restart Apache I hope it will be helpful for those who have the same problem 保存并重新启动Apache,希望对那些有相同问题的人有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM