Zend_Gdata库和Picasa数据API-缺少loader.php文件 [英] Zend_Gdata library and Picasa data API -- loader.php file missing

查看:87
本文介绍了Zend_Gdata库和Picasa数据API-缺少loader.php文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用php开发一个应用程序,以使用Zend_Gdata库从picasa下载图片. 我的项目文件夹结构是这样的:

Im trying to develop an application in php to download pics from picasa using Zend_Gdata library. My project folder structure is like this:

www(wamp)
  /project
    test.php
    /Zend
      /Authentication
      /Barcode
      .
      .
      /View
      /XmlRpc

如您所见,我还没有复制完整的Zend框架.我不希望这个项目中有完整的MVC范例,而只是Zend_Gdata库.这是这样做的方法吗?还是我必须使用完整的zend框架?我对Zend完全陌生.

As you can see, i havent copied the full Zend Framework. I dont want the full MVC paradigm in this project, just the Zend_Gdata library. Is this the way to do this? Or do i have to use the complete zend framework? Im completely new to Zend.

我在IBM网站 http://www.ibm.com/上找到了这篇文章. developerWorks/library/x-picasalbum/进行了很好的解释.

I found this article at IBM site http://www.ibm.com/developerworks/library/x-picasalbum/ very well explained.

但是我似乎无法在该教程的Listing5中指定的Zend文件夹中找到 Loader.php 文件.

But i cant seem to find the Loader.php file in Zend folder specified in the Listing5 of that tutorial.

// load library
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Photos');
Zend_Loader::loadClass('Zend_Http_Client');

相反,我在Zend文件夹中找到了这个文件夹 Loader ,其中还有很多其他的loaderClasses.那本教程过时了吗? (其日期为2008年9月16日; Zend现在为Zend2).该文件夹中的哪个文件用于旧的Loader.php?

Instead i found this folder Loader in the Zend folder with lots of other loaderClasses. Is that tutorial outdated? (its dated 16-Sep-2008; Zend is now Zend2) Which file in that folder serve the purpose of old Loader.php?

推荐答案

如果使用的是Zend Framework 1,则必须首先将Zend文件夹添加到include_path

If you are using Zend Framework 1 you must first add the Zend folder to your include_path

set_include_path(implode(PATH_SEPARATOR, array(
    realpath(realpath(dirname(__FILE__) . '/../library'), // /../library is the relative path to the Zend folder 
    get_include_path(),
)));

然后设置自动加载器(此代码至少需要框架的v1.12版)

Then setup the autoloader (this code requires at least v1.12 of the framework)

require_once __DIR__ . '/../library/Zend/Loader/StandardAutoloader.php';
$loader = new Zend_Loader_StandardAutoloader(
    array(
         Zend_Loader_StandardAutoloader::LOAD_NS => array(
             'Zend'     => __DIR__ . '/../library/Zend',
         ),
    ));
$loader->register();

如果您使用的是Zend Framework 2,则必须使用

If you are using Zend Framework 2 then you must use

require_once __DIR__ . '/../library/Zend/Loader/StandardAutoloader.php';
$loader = new Zend\Loader\StandardAutoloader(
    array(
         Zend\Loader\StandardAutoloader::LOAD_NS => array(
             'Zend'     => __DIR__ . '/../library/Zend',
             'ZendGData'=> __DIR__ . '/../library/ZendGData',
         ),
    ));
$loader->register();

以上说明设置了自动加载器,因此您无需加载每个类.

The instructions above setup the autoloader so you don't need load each class.

在ZF1中,您可以直接执行以下操作:

In ZF1 you can do directly:

$var = new Zend_Gdata_ClientLogin()

ZF2中的相同之处是:

The same in ZF2 is:

$var = new ZendGData\ClientLogin();

这篇关于Zend_Gdata库和Picasa数据API-缺少loader.php文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆