Zend_Gdata library and Picasa data API — loader.php file missing

假装没事ソ 提交于 2019-12-11 14:44:41

问题


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

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.

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

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');

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?


回答1:


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(),
)));

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();

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.

In ZF1 you can do directly:

$var = new Zend_Gdata_ClientLogin()

The same in ZF2 is:

$var = new ZendGData\ClientLogin();


来源:https://stackoverflow.com/questions/12346180/zend-gdata-library-and-picasa-data-api-loader-php-file-missing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!