1

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?

Ivin
  • 4,435
  • 8
  • 46
  • 65

1 Answers1

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();
Maks3w
  • 6,014
  • 6
  • 37
  • 42
  • Thanks for your reply. I havent used full zend folder i downloaded from site. I have used the Zend folder only and its a sibling to my test.php. So do i need to use that type of require_once? Wont require_once('Zend/Loader/StandardAutoloader.php') work? – Ivin Sep 10 '12 at 07:18
  • I didnt get any folder name ZendGData in the download. And when searched their site this page=> http://framework.zend.com/download/gdata is missing. Is there any other place where i can get gdata? – Ivin Sep 10 '12 at 07:31
  • ZendGData is the new name of the component in ZF2 and you can download the sources from https://github.com/zendframework/ZendGData or if you want to a package manager (like Pyrus or Composer) then http://packages.zendframework.com/ – Maks3w Sep 10 '12 at 09:15
  • Thanks a lot @Maks3w. It worked. Do you know any place where i can get a documentation or list of functions under GData for Zend2? – Ivin Sep 10 '12 at 09:39
  • At this moment the API is very similar to the ZF1 version, just change the classes prefixes – Maks3w Sep 10 '12 at 10:38