CodeIgniter with Zend Framework Libraries

Sun, Jan 18, 2009

CodeIgniter, PHP

After several additional months of developing PHP applications with CodeIgniter, I am still very pleased with the platform and the suite tools that it provides. I know what it takes to write an application framework, so I appreciate the simplicity in its design. In my opinion, it is just enough framework to get the job done without restricting your development style, and that’s hard to come by.

That being said, I also like the suite of libraries that are part of the Zend Framework, especially the services! As of this post, they support Amazon, Delicious, Flickr, Google, Technorati, Twitter, Yahoo, and more! Now I know there is nothing like writing your own API integrations, and believe me, I’ve done my share; however there is something to be said for having someone else support those API integrations and keep them updated for you. You won’t hear any complaints from me!

You may think that integrating two different PHP frameworks is not possible, and that is probably true with other frameworks. However in this case, the Zend components are stand-alone and can be used-at-will, so this means they can easily be integrated into any CodeIgniter installation with very little effort. Nice!

As with any integration, there is more than one way to get the job done. So, I’ll just show you one way.

Step 1: Download the latest version of Zend Framework.

Extract the files and locate the “Zend” directory. (This is where all of the components live).

Step 2: Copy the Zend directory to your CodeIgniter’s library directory.

At this point, you can either selectively copy the sub directories or copy them all. Remember that the Zend components are stand-alone, so it’s up to you.

Step 3: Set the PHP include_path to the location of your Zend directory from Step 2.

Again, there are several ways to do this, but in my opinion, the simplest is to add an ini_set methods just below the BASEPATH define in your CodeIgniter’s index.php file or the applications dispatch file if you renamed it.

...
define('BASEPATH', $system_folder.'/');
ini_set('include_path',ini_get('include_path').':'.BASEPATH.'../system/application/libraries/');
...

Note: Your include path may vary. Simply update it as needed.

Step 4: Start using the integrated components by including them “at-will” and enjoy!

(I’ll update this post with an example shorty.)

As I mentioned earlier, there is more than one way to do this. Here are a few of the others:

, , ,

This post was written by:

Michael - who has written 4 posts on gotPHP.

I am an entrepreneur, a developer, a father, & a husband; in no particular order, unless of course you ask my wife. :)

Contact the author

Leave a Reply