

In this article I describe how to use Zend framework components in a CakePHP application by means of building a very simple CakePHP application using Zend_Service_Flickr, a component for accessing the Flickr web services.
Before we can start baking we have to do some preparations. First of all, this article is for those who are at least familiar with using CakePHP at a very basic level. If you are not yet introduced to CakePHP, please check out the Overview on CakePHP by Fabio Cevasco here at A/R/T. Now, onto the actual preparations:
1. Make sure you installed PHP 5 as the Zend framework requires PHP 5.
2. I assume you have already installed CakePHP. If that is not the case, download it from http://cakeforge.org/projects/cakephp/ and follow the installation instructions on http://manual.cakephp.org/chapter/3. I used version 1.1.6.3264 of CakePHP for this article.
3. Download the Zend framework from http://framework.zend.com/download.
4. Copy the content of the directory ZendFramework-0.1.5/library from the zipped file to <where_you_installed_cakephp>/app/vendors.
With that, the preparations are done. We are ready for baking our cake.
In our first iteration we will build the skeleton of our application. Our goal is to get an empty page when calling our controller. Yes, I know, the result of an iteration should be something of value for the user, so this iteration is an exception.
We start with the model which we call simply “Flickr”. What functionality should our model provide? For our simple application we only need one method which returns images for a tag. So we get the following class:
Notice that we have to add “var $useTable = false;” as our model will use a webservice and not a table.
Our model will be used, of course, by a controller. To make use of CakePHP's magic we name it “FlickrController”. The functionality of our controller is simple: it needs a method which gets the data from the Flickr model and hands the data over to the view. So we can write our controller:
The last step is the view. It is self-explanatory.
Our first iteration is almost done. Time to test what we have done. Open <yourdomain>/flickr/show/tree in your browser and you should get an empty page. Not really interesting, is it? So we move directly to the second iteration.

