1

你能告诉我我的 ZF 装载机做错了什么吗?我将我的 ZF 库放在library/Zend/*

在我的index.php文件中,我不断收到此错误:

*Warning: require_once(Zend/Gdata/Media.php): failed to open stream: No such file or 
 directory in C:\workspace\testing\library\Zend\Gdata\YouTube.php on line 27

索引.php:

require_once 'library/Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube', array('library/', 'library/Zend/', 'library/Zend/Gdata'));
4

1 回答 1

1

如果您的文件结构如此,我相信以下内容应该有效

./  (  == c:\workspace\testing\ )
./index.php
./library/
./library/Zend/
./library/Zend/GData/
./library/Zend/GData/YouTube.php
./library/Zend/GData/YouTube/...

索引.php

// We need 'Zend' folder to be 'level 1' child folder of a include_path directive
ini_set('include_path', 
    ini_get('include_path') . 
    PATH_SEPARATOR . 
    dirname(__FILE__). DIRECTORY_SEPARATOR. 'library');

// Option 1
require_once 'Zend/Loader/Autoloader.php';
$gdata = new Zend_GData_Youtube();

// Option 2
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');
$gdata = new Zend_Gdata_Youtube();

// Option 3 (with no include_path set)
require_once 'Zend/Loader.php';
$dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'library';
// backwards, recursively repeat loading classes which are dependencies of Gdata module
// foreach ( requestedModule::depends as $loadme )                        // PS: bogus code
//   loadClass($loadme, $dir)
Zend_Loader::loadClass('Zend_Gdata_Media', $dir);
Zend_Loader::loadClass('Zend_Gdata_YouTube', $dir);
$gdata = new Zend_Gdata_Youtube();
于 2012-08-05T20:57:18.013 回答