Zend:如何防止includePath中的双重库?

问题描述:

Zend Quick StartZend:如何防止includePath中的双重库?

公共/ index.php的

set_include_path(implode(PATH_SEPARATOR, array(
    dirname(dirname(__FILE__)) . '/library', 
    get_include_path(), 
))); 

CONFIGS /的application.ini

includePaths.library = APPLICATION_PATH "/../library" 

如从INI结果

print get_include_path(); 
// prints %localpath%/application/../library:%localpath%/library 

如果滴 “includePaths.library” ,./zf(Zend_Tool)失败。如果在index.php中,引导失败。

如何正确地防止这种重复?

+0

你在哪里放置'print get_include_path()'来测试这个?例如,您是否在其他地方设置了include路径(可能是php.ini?) –

+0

IndexController :: indexAction()。 没有其他的包含路径操作 – Dmitry

+0

据我所知,我可以通过set_include_path在bootstrap中简化硬编码includePath而不保存旧的includepath组件,但为什么需要在ini中包含选项“includePaths”,如果它无法正确使用 – Dmitry

我认为你是对的,包含路径不应该在application.ini中,所以我会删除它。然后让Zend的工具的工作,我认为你有两个选择:

  1. 更改设置要像在这个问题上的回答:Zend tool include path(这将有利于ZF发现包括路径)。 ZF的汽车发现在一路上发生了变化,但我不确定这种方法是否仍然有效。

  2. 或者,您可以设置一个环境变量来给Zend Tool库位置,详细信息如下:http://framework.zend.com/manual/1.12/en/zend.tool.framework.clitool.html(请参阅标题为“其他设置注意事项”的部分)。

就我个人而言,我只是跳过Zend工具 - 我不认为它真的让事情变得更容易。