<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CodeIgniter Tutorial</title>
	<atom:link href="http://www.gotphp.com/tag/libraries/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gotphp.com</link>
	<description>Practical Coding Examples and Advice For PHP Developers</description>
	<lastBuildDate>Tue, 06 Sep 2011 01:01:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>CodeIgniter with Zend Framework Libraries</title>
		<link>http://www.gotphp.com/codeigniter-with-zend-framework-libraries/54312/</link>
		<comments>http://www.gotphp.com/codeigniter-with-zend-framework-libraries/54312/#comments</comments>
		<pubDate>Sun, 18 Jan 2009 14:49:20 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[libraries]]></category>
		<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[zend libraries codeigniter]]></category>

		<guid isPermaLink="false">http://www.gotphp.com/?p=312</guid>
		<description><![CDATA[** UPDATED on 2010-09-06 ** 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<a class="moretag" href="http://www.gotphp.com/codeigniter-with-zend-framework-libraries/54312/">&#160;&#160;Full Article&#8230;</a>
]]></description>
			<content:encoded><![CDATA[<p><strong>** UPDATED on 2010-09-06 **</strong></p>
<p>After several additional months of developing PHP applications with <a href="http://codeigniter.com/">CodeIgniter</a>, 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&#8217;s hard to come by.</p>
<p>That being said, I also like the suite of libraries that are part of the <a href="http://framework.zend.com/">Zend Framework</a>, 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&#8217;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&#8217;t hear any complaints from me!</p>
<p>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!</p>
<p>As with any integration, there is more than one way to get the job done. So, I&#8217;ll just show you one way.</p>
<h2 id="section-1">Step 1: Download the latest version of Zend Framework.</h2>
<p><em>Extract the files and locate the &#8220;/library/Zend&#8221; directory. (This is where all of the components live).</em></p>
<h2 id="section-2">Step 2: Copy the Zend directory to your CodeIgniter&#8217;s library directory.</h2>
<p><em>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&#8217;s up to you.</em></p>
<h2 id="section-3">Step 3: Set the PHP include_path to the location of your Zend directory from Step 2.</h2>
<p><em>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&#8217;s index.php file or the applications dispatch file if you renamed it.</em></p>
<pre class="brush:php">
// defined for easy access to Zend libs by gotphp.com
if (!defined("PATH_SEPARATOR")) {
	if (strpos($_ENV["OS"], "Win") !== FALSE) {
		define("PATH_SEPARATOR", ";");
	} else {
		define("PATH_SEPARATOR", ":");
	}
}
ini_set('include_path',ini_get('include_path').PATH_SEPARATOR.BASEPATH.'../system/application/libraries/');
</pre>
<p><em>Note: The above code should work for most CodeIgniter installations however your include path may vary. Simply update it as needed.</em></p>
<h2 id="section-4">Step 4: Start using the integrated components by including them &#8220;at-will&#8221; and enjoy!</h2>
<p><em>Here is a simple example of how to use Zend&#8217;s RSS library to read an RSS feed.</em></p>
<p><strong>Example Controller:</strong></p>
<pre class="brush:php">
class Zendexample extends MY_Controller {

	// --------------------------------------------------------------------

	/**
	 *	The constructor
	 */
	function __construct()
	{
		parent::__construct();	

		// IMPORTANT: You must require or include the Zend library you are
		// about to use that has been uploaded to: /apps/main/libraries/Zend/*
		//
		// TIP #1: You only need to upload the libraries you plan to use. Some
		// Zend libraries have dependencies so those will need to be uploaded
		// too.
		//
		// TIP #2: You can include the Zend files from anywhere in your app.
		require("Zend/Feed/Rss.php");
	}

	// --------------------------------------------------------------------

	/**
	 *	The default method for this controller
	 */
	function index()
	{

		// You can reference the Zend manual for how to use Zend libraries
		// http://framework.zend.com/manual/en/zend.feed.consuming-rss.html

		// Fetch an RSS feed using the Zend RSS library
		$output = new Zend_Feed_Rss('http://www.gotphp.com/feed');

		// Add the RSS to CodeIgniter's template data
		$this->tpl_data += array(
			'rss' => $output
		);

		// Call the display template (/apps/main/views/zendexample.php)
		//
		// TIP #1: $this->_tpl is defined in the parent controller MY_Controller
		// and wraps the template between header &#038; footer templates already.
		//
		// TIP #2: $this->tpl_data will be available to all view templates so
		// you can add anything you want to it from this controller.
		$this->_tpl('zendexample');
	}

	// --------------------------------------------------------------------

}
</pre>
<p><strong>Example View:</strong></p>
<pre class="brush:php">
<h1 id="section-5">Zend Example - Pulling in an RSS Feed</h1>

<strong>RSS Feed:</strong> < ?=$rss->title();?>
<ul>
< ?php foreach($rss as $item): ?>
<li>< ?=anchor($item->link(), $item->title(), 'target="_blank"')?></li>

< ?php endforeach; ?>
</ul>
</pre>
<p><em>And here&#8217;s what the output will look like:</em></p>
<p><a href="http://www.gotphp.com/wp-content/gotphp-uploads/zend-libraries-feed-example.png"><img src="http://www.gotphp.com/wp-content/gotphp-uploads/zend-libraries-feed-example.png" alt="Zend Libraries Feed Example" title="Zend Libraries Feed Example" width="476" height="189" class="alignnone size-full wp-image-402" /></a></p>
<p><strong>I know this is a simple example, but there&#8217;s really not much to integrating Zend with CodeIgniter. For a lot of Zend&#8217;s libraries, it is that easy!</strong></p>
<p><script type="text/javascript" src="http://forms.aweber.com/form/32/159230832.js"></script></p>
<p><strong>If you found this article useful, please share your comments below.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gotphp.com/codeigniter-with-zend-framework-libraries/54312/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

