This article will describe shortly how you can extend the power of CakePHP using the Zend Framework. I know, earlier this week I talked about war when writing about these two. But, reactions from Wil and Richard changed my mind a little bit. Richard mentioned about the possibility to use Zend Components within CakePHP. I tested this for myself and it took me only a few minutes. The Zend Framework seems a little bit more flexible in a way that you choose for yourself about which components you use and which you don't use. CakePHP has a certain pattern in which you have to develop your applications. CakePHP is the framework I choose and like to work with. But, it would be handy if it could be easier to integrate with webservices or create PDFs etc. It is possible, but you have to look for the right component. The Zend Frameworks has many components built-in. Like support for Flickr and Delicious. I tried these two and that works ok.Ok, start the engines...
function index() { define('MY_API_KEY', 'yourkeyhere'); $path = APP.'/vendors'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); vendor('Zend/Service/Flickr'); $flickr = new Zend_Service_Flickr(MY_API_KEY); $results = $flickr->tagSearch('zend'); $this->set('images', $results);}
< ?php foreach ($images as $image): ?> < ?php echo $html->image($image->Thumbnail->uri); ?> < ?php echo "{$image->title}\n"; ?>< ?php endforeach; ?>
I tried this with Del.icio.us also and it works great. Let us know if you tried other components and what the results are!Just modified code a little thanks to Richard.Have a look at http://framework.zend.com/wiki/display/ZFPROP/Home. They are working on more stuff. For example a Twitter component. Works too, but you have to: vendor('Zend/Rest/Client'); vendor('Zend/Service/Twitter');
