无法让zend加载器仅在wamp下加载类

时间:2009-11-02 00:30:21

标签: php zend-framework zend-loader

我第一次尝试了zend框架类。我现在有兴趣使用一些单独的课程。 阅读文档和其他一些q在这里和博客我已经尝试了三种方法来加载类

    //attempt 1 - using zend loader
require_once('library\Zend\Loader.php');
Zend_Loader::loadClass('Zend_Date');

    //attempt 2 - direct class load
require_once('library\Zend\Date.php');

    // attempt 3 - auto load
set_include_path('D:\wamp\www\testPages\zend_test\library\Zend' . PATH_SEPARATOR . get_include_path());
require_once 'Loader\Autoloader.php';


$date = new Zend_Date();

// Output of the desired date
print $date->get();

我的文件夹结构是:

  • zend_test(文件夹)
    - testLoad.php(上面的代码住在那里)
    - 图书馆(文件夹)
    --- zend(doler)
    ----(zend libs和子文件夹)

我收到以下错误消息: 尝试1

Warning: include(Zend\Date.php) [function.include]: failed to open stream: No such file or directory in D:\wamp\www\testPages\zend_test\library\Zend\Loader.php on line 83

Warning: include() [function.include]: Failed opening 'Zend\Date.php' for inclusion (include_path='.;C:\php5\pear') in D:\wamp\www\testPages\zend_test\library\Zend\Loader.php on line 83

Warning: require_once(Zend/Exception.php) [function.require-once]: failed to open stream: No such file or directory in D:\wamp\www\testPages\zend_test\library\Zend\Loader.php on line 87

Fatal error: require_once() [function.require]: Failed opening required 'Zend/Exception.php' (include_path='.;C:\php5\pear') in D:\wamp\www\testPages\zend_test\library\Zend\Loader.php on line 87

ATTEMPT2

Warning: require_once(Zend/Date/DateObject.php) [function.require-once]: failed to open stream: No such file or directory in D:\wamp\www\testPages\zend_test\library\Zend\Date.php on line 25

Fatal error: require_once() [function.require]: Failed opening required 'Zend/Date/DateObject.php' (include_path='.;C:\php5\pear') in D:\wamp\www\testPages\zend_test\library\Zend\Date.php on line 25

atempt3

Warning: require_once(Zend/Loader.php) [function.require-once]: failed to open stream: No such file or directory in D:\wamp\www\testPages\zend_test\library\Zend\Loader\Autoloader.php on line 24
Fatal error: require_once() [function.require]: Failed opening required 'Zend/Loader.php' (include_path='D:\wamp\www\testPages\zend_test\library\Zend;.;C:\php5\pear') in D:\wamp\www\testPages\zend_test\library\Zend\Loader\Autoloader.php on line 24

我错过了什么吗?

3 个答案:

答案 0 :(得分:3)

您的包含路径应​​为:

include_path='D:\wamp\www\testPages\zend_test\library;.;C:\php5\pear

当它尝试加载Zend_Date类时,它会在include路径中查找名为Zend的文件夹,其中包含一个名为Date.php的文件。

所有3种方法都应该使用此更正,我建议尝试3。

答案 1 :(得分:1)

使用方法3并执行此操作以使其正常工作:

set_include_path('D:/wamp/www/zendTest/library/');   
require_once 'Zend/Loader/Autoloader.php';

Zend_Loader::loadClass('Zend_Date'); //or whatever zen class

答案 2 :(得分:0)

在php.ini中删除“;”在行include_Path之前,重新启动你的wamp!