Zend Framework’s beauty is it’s range of services or web API, like Delicious, Flickr, GData and a lot more. build into it by default. CakePHP’s beauty is that you can extend it, extend it way up to the point where you can import other framework and make use of that framework’s feature. Having said that, Zend inside CakePHP would be totally awesome. The inspiration behind was this blog post http://britg.com/2008/07/07/using-the-zend-framework-in-cakephp/ but i will show you how to use the flickr service.

First download the minimal version of Zend Framework (It will ask you 2-3 times on what you want to download and will ask for you to login/register and i think this is insane). Anyway after downloading extract the files to your folder so that you will have a folder structure like
vendors
---Zend
------Everything that is inside the folder library/Zend

After that, as what britg.com said about the config file, import the following lines in core.php
ini_set('include_path',ini_get('include_path') . PATH_SEPARATOR . '/path/to/vendors/');

Alibris

Then you’re ready to use Zend’s feature in cake.
function getArtistImage($id){
$this->Artist->id = $artistId;
$artistData = $this->Artist->read();
if($artistData){
App::import("vendor",'Zend_Service_Flickr',array("file"=>'Zend/Service/Flickr.php'));
$flickr = new Zend_Service_Flickr('your flickr api key');
$artistName = $artistData['Artist']['name'];
$results = $flickr->tagSearch($artistName);
$this->set(compact(”results”,”artistName”));
}
}

Then in your view
<? foreach ($results as $result): ?>
<img src="<?=$result->Small->uri;?>"
height="<?=$result->Small->height;?>" width="<?=$result->Small->width;?>"
>
<? endforeach; ?>

To further explain a bit
App::import(”vendor”,’Zend_Service_Flickr’,array(”file”=>’Zend/Service/Flickr.php’));
– this imported the flickr api

$flickr = new Zend_Service_Flickr(’your flickr api key’);
– this creates a new instance of the flickr service

$artistName = $artistData['Artist']['name'];
$results = $flickr->tagSearch($artistName);
– this searches the artist’s name on the tags on flickr

Here is an example of this post
http://monmonja.com/music/lyrics/flickr/87

Share and Enjoy:
  • Digg
  • Reddit
  • Slashdot
  • del.icio.us
  • StumbleUpon
  • TwitThis
  • Fark
  • Facebook
  • Technorati
  • Sphinn
  • Furl
  • Google
  • Mixx