1

我是第一次尝试 zend 框架类。我现在有兴趣使用一些单独的类。在此处和博客中阅读文档和其他一些问题,我尝试了三种加载类的方法

    //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(folder)
    -- testLoad.php (上面的代码在那里)
    -- library(folder)
    --- 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

尝试2

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

尝试3

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

我错过了什么吗?

4

3 回答 3

3

您的包含路径应​​为:

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

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

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

于 2009-11-02T00:43:39.357 回答
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
于 2009-11-23T12:56:16.773 回答
0

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

于 2013-02-09T10:14:47.280 回答