<?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>Emran Hasan&#039;s Blog &#187; Code Igniter</title>
	<atom:link href="http://phpfour.com/blog/tag/code-igniter/feed/" rel="self" type="application/rss+xml" />
	<link>http://phpfour.com/blog</link>
	<description>The everyday sharing of Emran Hasan on software development.</description>
	<lastBuildDate>Fri, 20 Jan 2012 11:39:05 +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>Changing the default controller naming convention in CodeIgniter</title>
		<link>http://phpfour.com/blog/2009/09/codeigniter-controller-naming-convention-modified/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=codeigniter-controller-naming-convention-modified</link>
		<comments>http://phpfour.com/blog/2009/09/codeigniter-controller-naming-convention-modified/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 06:23:04 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Code Igniter]]></category>
		<category><![CDATA[core]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[library]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=265</guid>
		<description><![CDATA[CodeIgniter is one of my favorite framework and I often use it for developing application quickly. Although it is very flexible in most cases, I find its naming convention to be strict. Many times I have faced this problem when my controller&#8217;s class name and a model/library&#8217;s class names are the same &#8211; a Fatal [...]]]></description>
			<content:encoded><![CDATA[<p>CodeIgniter is one of my favorite framework and I often use it for developing application quickly. Although it is very flexible in most cases, I find its naming convention to be strict. Many times I have faced this problem when my controller&#8217;s class name and a model/library&#8217;s class names are the same &#8211; a Fatal error is inevitable and I have to forcefully change the name of the conflicting class to something less desirable (say from Users to UsersModel). Today I wanted to end this problem.</p>
<p>So I extended the <strong>CI_Router</strong> core class and made change to the <em>_validate_request</em> method. Now I can name my controller classes in this fashion: <strong>UsersController</strong> and it resides on the file system as <strong>controllers/UsersController.php</strong>. If you&#8217;ve tried other established frameworks, you should notice that this naming convention is widely used. So, if you have the same need, then just download the MY_Router.php file and put it on your application/libraries folder. That&#8217;s it.</p>
<p>Here is how your controller would start:</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #000000; font-weight: bold;">class</span> UsersController <span style="color: #000000; font-weight: bold;">extends</span> Controller<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p><span id="more-265"></span><br />
If you&#8217;d like to have a look at the code, here is the source for quick view:</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <a href="http://www.php.net/defined"><span style="color: #990000;">defined</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'BASEPATH'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'No direct script access allowed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">/*<br />
&nbsp;* MY_Router<br />
&nbsp;*<br />
&nbsp;* Extended the core CI_Router class in order to force a different naming<br />
&nbsp;* convention for controllers.<br />
&nbsp;*<br />
&nbsp;*/</span><br />
<span style="color: #000000; font-weight: bold;">class</span> MY_Router <span style="color: #000000; font-weight: bold;">extends</span> CI_Router<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; &nbsp;* Suffix in controller name<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* @var String<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_suffix</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Controller&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; &nbsp;* Call the parent constructor<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* This is a requirement for extending base CI core class. Just abiding by<br />
&nbsp; &nbsp; &nbsp;* the rules.<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* @access &nbsp;public<br />
&nbsp; &nbsp; &nbsp;* @return &nbsp;void<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MY_Router<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; parent<span style="color: #339933;">::</span><span style="color: #004000;">CI_Router</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* Validates the supplied segments. &nbsp;Attempts to determine the path to<br />
&nbsp; &nbsp; &nbsp;* the controller.<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* @access &nbsp; private<br />
&nbsp; &nbsp; &nbsp;* @param &nbsp; &nbsp;array<br />
&nbsp; &nbsp; &nbsp;* @return &nbsp; array<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> _validate_request<span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Retain the original segments</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$orgSegments</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array_slice"><span style="color: #990000;">array_slice</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Add suffix to the end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ucfirst"><span style="color: #990000;">ucfirst</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_suffix<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Does the requested controller exist in the root folder?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_exists"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span>APPPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'controllers/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span>EXT<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$segments</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// OK, revert to the original segment</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$orgSegments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Is the controller in a sub-folder?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_dir"><span style="color: #990000;">is_dir</span></a><span style="color: #009900;">&#40;</span>APPPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'controllers/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Set the directory and remove it from the segment array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_directory</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$segments</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array_slice"><span style="color: #990000;">array_slice</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Add suffix to the end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ucfirst"><span style="color: #990000;">ucfirst</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_suffix<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Does the requested controller exist in the sub-folder?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <a href="http://www.php.net/file_exists"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span>APPPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'controllers/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_directory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span>EXT<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; show_404<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_directory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Add suffix to the end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_controller</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ucfirst"><span style="color: #990000;">ucfirst</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_controller</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_suffix<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_class</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_controller</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_method</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'index'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Does the default controller exist in the sub-folder?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <a href="http://www.php.net/file_exists"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span>APPPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'controllers/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_directory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_controller</span><span style="color: #339933;">.</span>EXT<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">directory</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$segments</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Can't find the requested controller...</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; show_404<span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2009/09/codeigniter-controller-naming-convention-modified/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Code Updates (HTTP class, Extended CodeIgniter Model, Cross-domain AJAX transport)</title>
		<link>http://phpfour.com/blog/2009/02/updated-http-class-extended-model-codeigniter-cross-domain-ajax-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=updated-http-class-extended-model-codeigniter-cross-domain-ajax-php</link>
		<comments>http://phpfour.com/blog/2009/02/updated-http-class-extended-model-codeigniter-cross-domain-ajax-php/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 21:27:47 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[Code Igniter]]></category>
		<category><![CDATA[cross-domain]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[essential]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=186</guid>
		<description><![CDATA[Greetings to all the readers of my blog. Many of you have been writing to me in the last couple days when I took the site down. The main objective was to add the new theme and push a few code updates of the existing libraries. I really appreciate your concern and would like to [...]]]></description>
			<content:encoded><![CDATA[<p>Greetings to all the readers of my blog.</p>
<p>Many of you have been writing to me in the last couple days when I took the site down. The main objective was to add the new theme and push a few code updates of the existing libraries. I really appreciate your concern and would like to reassure you that the site is up and will be up as usual <img src='http://phpfour.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Now, besides the slightly customized theme from Elegant Themes, I have put a few code updates. They are detailed below:</p>
<h3>Extended Model for CodeIgniter</h3>
<p>The <a href="http://www.phpfour.com/blog/2008/07/extended-model-for-codeigniter/">original version</a> of the Extended Model for CodeIgniter has been serving many people well. Although most users loved the nifty functions of the Model, many (including me) didn&#8217;t like the hacking of CI core to get this functionality. With the release of CodeIgniter 1.7, we can avoid that as we can now overload the Model class of CI like the other libraries. Follow this instruction:</p>
<p>1. Download the updated version from <a href="http://www.phpfour.com/blog/downloads/model-ci-2">here</a><br />
2. Put it in your application/libraries folder<br />
3. In your model files, use it this way: <strong>class Product extends MY_Model</strong><br />
4. Everything else is same just like the <a href="http://www.phpfour.com/blog/2008/07/extended-model-for-codeigniter/">original</a> one</p>
<h3>HTTP Class</h3>
<p>There is not much update in this class except for a few bug fixes (thanks to you guys). Also, I have included a license file in the package as many of you have asked. It&#8217;s released under the MIT license. The original post is <a href="http://www.phpfour.com/blog/2008/01/php-http-class/">here</a> for reference.</p>
<p>Download the update from <a href="http://www.phpfour.com/blog/downloads/http-class">here</a> and the API reference is <a href="http://www.phpfour.com/lib/http">here</a>.</p>
<h3>Cross-domain AJAX calls using PHP</h3>
<p>A minor bug fix in the code. Thanks to a few of you who pointed them out. Original post is <a href="http://www.phpfour.com/blog/2008/03/cross-domain-ajax-using-php/">here</a>. Download the update from <a href="http://www.phpfour.com/blog/downloads/transport">here</a>.</p>
<p>I have accelerated plans for the blog in 2009 so stay tuned for some worthy posts in this month. And do <a href="http://www.phpfour.com/blog/contact-me/">write to me</a> if you feel you have any questions/ideas/suggestions.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2009/02/updated-http-class-extended-model-codeigniter-cross-domain-ajax-php/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Extended Model for CodeIgniter</title>
		<link>http://phpfour.com/blog/2008/07/extended-model-for-codeigniter/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=extended-model-for-codeigniter</link>
		<comments>http://phpfour.com/blog/2008/07/extended-model-for-codeigniter/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 20:59:03 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[RBS]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[Code Igniter]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=104</guid>
		<description><![CDATA[Feb 2009: An updated version of the code for CodeIgniter 1.7.x can be found here. I developed this extension of CodeIgniter&#8217;s Model last year, but never had the chance to publish it. The main purpose of this extension is to make a dev&#8217;s life easy. This extension has been used by several of my devs [...]]]></description>
			<content:encoded><![CDATA[<blockquote class="left"><p><strong>Feb 2009: An updated version of the code for CodeIgniter 1.7.x can be found</strong> <a href="http://www.phpfour.com/blog/2009/02/updated-http-class-extended-model-codeigniter-cross-domain-ajax-php/">here</a>.
</p></blockquote>
<p>I developed this extension of CodeIgniter&#8217;s Model last year, but never had the chance to publish it. The main purpose of this extension is to make a dev&#8217;s life easy. This extension has been used by several of my devs at <a target="_blank" href="http://www.rightbrainsolution.com" title="Download Model">RBS</a> and has been proved to increase productivity and reduce the number of painful small queries to write. Their enthusiasm has driven me to post this for the CI fans out there.</p>
<p>Without much babble, let&#8217;s get into point. I&#8217;ve explained the process of installing it and then showed some example uses. For starter, click <a target="_blank" href="http://www.phpfour.com/blog/downloads/model-ci" title="Download Model">here</a> to download it. Now follow these steps to get started:</p>
<p><span id="more-104"></span></p>
<p>1. Replace the system/libraries/Model.php file with the attached Model.php (CodeIgniter version 1.6.3)</p>
<p>2. For each of your tables, you will need to create a model file in system/application/models. </p>
<p>3. Lets say we have a &quot;products&quot; table whose schema is as follows:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">TABLE</span> `products` (</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>       `id` <span style="color: #0000ff">int</span>(11) <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span> auto_increment,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>       `title` <span style="color: #0000ff">varchar</span>(50) <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>       `description` text <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>       `color` <span style="color: #0000ff">varchar</span>(20) <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>       `price` <span style="color: #0000ff">float</span> <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>       `category_id` <span style="color: #0000ff">int</span>(11) <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>       `featured` <span style="color: #0000ff">char</span>(1) <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>       `enabled` <span style="color: #0000ff">char</span>(1) <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>       `visits` <span style="color: #0000ff">int</span>(1) <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>       `created` <span style="color: #0000ff">int</span>(11) <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>       `modified` <span style="color: #0000ff">int</span>(11) <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>       <span style="color: #0000ff">PRIMARY</span> <span style="color: #0000ff">KEY</span>  (`id`)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>     ) ENGINE=MyISAM;</pre>
</p></div>
</div>
<p>4. Now we need to create system/application/models/product.php:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> &lt;?php  <span style="color: #0000ff">if</span> (!defined(<span style="color: #006080">'BASEPATH'</span>)) exit(<span style="color: #006080">'No direct script access allowed'</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     <span style="color: #0000ff">class</span> Product extends Model {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>         function Product()</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>         {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>             <span style="color: #008000">// Call the Model constructor</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>             parent::Model();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>             </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>             <span style="color: #008000">// Load the associated table</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>             $<span style="color: #0000ff">this</span>-&gt;loadTable(<span style="color: #006080">'products'</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>         }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>     }</pre>
</p></div>
</div>
<p>5. From any controller, you can load the Model as instructed in the CI manual. Here are some sample usage of the model functions:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> function products()</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>     {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>         <span style="color: #008000">// Load the model in the default way</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>         $<span style="color: #0000ff">this</span>-&gt;load-&gt;model(<span style="color: #006080">'Product'</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>         <span style="color: #008000">// Total # of products</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>         echo $<span style="color: #0000ff">this</span>-&gt;Product-&gt;findCount();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>         <span style="color: #008000">// Total # of featured products</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>         echo $<span style="color: #0000ff">this</span>-&gt;Product-&gt;findCount(<span style="color: #006080">&quot;featured = 'Y'&quot;</span>); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>         <span style="color: #008000">// Retrieve ALL the products</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>         $allProducts = $<span style="color: #0000ff">this</span>-&gt;Product-&gt;findAll(); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>         <span style="color: #008000">// Retrive id, title and price of top 10 products (based on popularity) that are enabled</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>         $topProducts = $<span style="color: #0000ff">this</span>-&gt;Product-&gt;findAll(<span style="color: #006080">&quot;enabled = 'Y'&quot;</span>, <span style="color: #006080">'id, title, price'</span>, <span style="color: #006080">'visits DESC'</span>, <span style="color: #006080">'0'</span>, <span style="color: #006080">'10'</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>         <span style="color: #008000">// Retrive id, title and price of the 1st most popular product that is enabled</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span>         $topProducts = $<span style="color: #0000ff">this</span>-&gt;Product-&gt;find(<span style="color: #006080">&quot;enabled = 'Y'&quot;</span>, <span style="color: #006080">'id, title, price'</span>, <span style="color: #006080">'visits DESC'</span>, <span style="color: #006080">'0'</span>, <span style="color: #006080">'10'</span>); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span>         <span style="color: #008000">// Retrieve the product with id = 1</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span>         $oneProduct = $<span style="color: #0000ff">this</span>-&gt;Product-&gt;read(1); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  23:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  24:</span>         <span style="color: #008000">// Retrive the price of the product whose id = 1</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  25:</span>         $productPrice = $<span style="color: #0000ff">this</span>-&gt;Product-&gt;field(<span style="color: #006080">'price'</span>, <span style="color: #006080">'id = 1'</span>); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  26:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  27:</span>         <span style="color: #008000">// Single array with the titles of all the enabled products</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  28:</span>         $productArr = $<span style="color: #0000ff">this</span>-&gt;Product-&gt;generateSingleArray(<span style="color: #006080">&quot;enabled = 'Y'&quot;</span>, <span style="color: #006080">'title'</span>); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  29:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  30:</span>         <span style="color: #008000">// Insert a new product in the db</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  31:</span>         $newProductId = $<span style="color: #0000ff">this</span>-&gt;Product-&gt;insert(array(<span style="color: #006080">'title'</span> =&gt; <span style="color: #006080">'New Product'</span>, <span style="color: #006080">'price'</span> =&gt; <span style="color: #006080">'10.99'</span>)); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  32:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  33:</span>         <span style="color: #008000">// Update the price of the newly added product</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  34:</span>         $updProduct = $<span style="color: #0000ff">this</span>-&gt;Product-&gt;save(array(<span style="color: #006080">'price'</span> =&gt; <span style="color: #006080">'20.00'</span>), $newProductId); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  35:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  36:</span>         <span style="color: #008000">// Delete the product</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  37:</span>         $<span style="color: #0000ff">this</span>-&gt;Product-&gt;remove($new_product_id);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  38:</span>     }</pre>
</p></div>
</div>
<p>7. There are a number of other helpful functions in this file. If you have a careful look, you&#8217;ll discover that some of them are really handy.</p>
<p>UPDATE: I forgot to give due credit to the wonderful developers of <a href="http://cakephp.org">CakePHP</a> &#8211; I&#8217;ve taken inspiration from their Model implementation while building this one for CodeIgniter. </p>
<h3>Download</h3>
<table cellspacing="0" cellpadding="2" border="0" width="698">
<tbody>
<tr>
<td width="42"><a target="_blank" href="http://www.phpfour.com/blog/downloads/model-ci" title="Download Model"><img src="http://www.phpfour.com/images/download.gif" border="0" /></a></td>
<td width="650"><strong>Model.php</strong><br/>Extended Model for CodeIgniter<br/>Downloaded: <strong></strong> times</td>
</tr>
</tbody>
</table>
<p><strong>MORE UPDATE:</strong> Download the version for CodeIgniter 1.7.x <a href="http://www.phpfour.com/blog/2009/02/updated-http-class-extended-model-codeigniter-cross-domain-ajax-php/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2008/07/extended-model-for-codeigniter/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Htpasswd protection library for Code Igniter</title>
		<link>http://phpfour.com/blog/2007/07/htpasswd-protection-library-for-code-igniter/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=htpasswd-protection-library-for-code-igniter</link>
		<comments>http://phpfour.com/blog/2007/07/htpasswd-protection-library-for-code-igniter/#comments</comments>
		<pubDate>Mon, 23 Jul 2007 10:46:10 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Code Igniter]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/2007/07/23/htpasswd-protection-library-for-code-igniter/</guid>
		<description><![CDATA[This is a library designed to run with Code Igniter that allows the application to protect any folder in the webserver using the htpasswd method of Apache. It can also group the users and create group based permission on the folders. The use is very simple: you need to define an array of the users [...]]]></description>
			<content:encoded><![CDATA[<p>This is a library designed to run with <em>Code Igniter</em> that allows the application to protect any folder in the webserver using the <strong>htpasswd method</strong> of Apache. It can also group the users and create group based permission on the folders. The use is very simple: you need to define an array of the users (and array of groups if you need that), tell it where to store the password files and tell which folder to protect. It will do the rest for you. Here goes the function:</p>
<div style="background-color:#eeeeee; font-size:12px;">
<font face="Courier New"><font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;</font><i><font color="#FF8000">/**</font></i><br />
<i><font color="#FF8000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Protect&nbsp;a&nbsp;given&nbsp;folder&nbsp;with&nbsp;htpasswd&nbsp;protection&nbsp;method</font></i><br />
<i><font color="#FF8000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</font></i><br />
<i><font color="#FF8000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</font></i><b><i><font color="#FF8000">@author</font></i></b><i><font color="#FF8000">&nbsp;&nbsp;Md&nbsp;Emran&nbsp;Hasan&nbsp;&lt;emran@rightbrainsolution.com&gt;</font></i><br />
<i><font color="#FF8000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</font></i><b><i><font color="#FF8000">@param</font></i></b><i><font color="#FF8000">&nbsp;&nbsp;&nbsp;string&nbsp;&nbsp;location&nbsp;of&nbsp;the&nbsp;folder&nbsp;to&nbsp;protect</font></i><br />
<i><font color="#FF8000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</font></i><b><i><font color="#FF8000">@param</font></i></b><i><font color="#FF8000">&nbsp;&nbsp;&nbsp;string&nbsp;&nbsp;location&nbsp;of&nbsp;the&nbsp;folder&nbsp;to&nbsp;write&nbsp;the&nbsp;group&nbsp;and&nbsp;password&nbsp;file</font></i><br />
<i><font color="#FF8000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</font></i><b><i><font color="#FF8000">@param</font></i></b><i><font color="#FF8000">&nbsp;&nbsp;&nbsp;array&nbsp;&nbsp;&nbsp;an&nbsp;array&nbsp;with&nbsp;the&nbsp;users&nbsp;info&nbsp;(username&nbsp;and&nbsp;password)</font></i><br />
<i><font color="#FF8000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</font></i><b><i><font color="#FF8000">@param</font></i></b><i><font color="#FF8000">&nbsp;&nbsp;&nbsp;array&nbsp;&nbsp;&nbsp;an&nbsp;array&nbsp;with&nbsp;the&nbsp;groups&nbsp;along&nbsp;with&nbsp;their&nbsp;user&nbsp;list</font></i><br />
<i><font color="#FF8000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</font></i><b><i><font color="#FF8000">@return</font></i></b><i><font color="#FF8000">&nbsp;&nbsp;boolean</font></i><br />
<i><font color="#FF8000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</font></i><b><i><font color="#FF8000">@access</font></i></b><i><font color="#FF8000">&nbsp;&nbsp;public</font></i><br />
<i><font color="#FF8000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</font></i><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;</font><b><font color="#000000">function</font></b><font color="#008080">&nbsp;</font><font color="#000000">protect</font>(<font color="#9D0000">$protectFolder</font><font color="#000000">,</font><font color="#008080">&nbsp;</font><font color="#9D0000">$passFolder</font><font color="#000000">,</font><font color="#008080">&nbsp;</font><font color="#9D0000">$userData</font><font color="#000000">,</font><font color="#008080">&nbsp;</font><font color="#9D0000">$groupData</font><font color="#008080">&nbsp;</font><font color="#000000">=</font><font color="#008080">&nbsp;</font><b><font color="#000000">array</font></b>())</font></p>
</div>
<p>It is a small part of the large protection library I have been developing for a membership management application called <strong>MemberSmart </strong>. This application allows someone to protect their PHP and non-PHP based files residing in a server in a number of ways. Among the methods, the htpasswd is the most easy and convenient one. This application will be released soon by the client I am working for.</p>
<p>Download the library with the example from <a href='http://www.phpfour.com/blog/wp-content/uploads/2007/07/htpasswd2.zip' title='htpasswd.zip'>htpasswd.zip</a>. Here is an example controller highlighting the use of the library.</p>
<div style="background-color:#eeeeee">
<font face="Courier New"><font size="2"><font color="#000000"><font color="#FF0000">&lt;?php<br />
</font><br />
<b><font color="#000000">class</font></b><font color="#008080">&nbsp;</font><font color="#000000">Protect</font><font color="#008080">&nbsp;</font><b><font color="#000000">extends</font></b><font color="#008080">&nbsp;</font><font color="#000000">Controller</font><font color="#008080">&nbsp;</font><font color="#000000">{<br />
</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;</font><b><font color="#000000">function</font></b><font color="#008080">&nbsp;</font><font color="#000000">Protect</font>()<br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">{</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">parent</font>::Controller();<br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;</font><b><font color="#000000">function</font></b><font color="#008080">&nbsp;</font><font color="#000000">index</font>()<br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">{</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><i><font color="#FF8000">//&nbsp;Load&nbsp;the&nbsp;library</font></i><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#9D0000">$this</font><font color="#000000">-&gt;</font>load-&gt;library(<font color="#008000">&#8216;AuthHtpasswd&#8217;</font><font color="#000000">);</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><i><font color="#FF8000">//&nbsp;Create&nbsp;the&nbsp;user&nbsp;array&nbsp;(this&nbsp;might&nbsp;come&nbsp;from&nbsp;your&nbsp;db)</font></i><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#9D0000">$userData</font><font color="#008080">&nbsp;</font><font color="#000000">=</font><font color="#008080">&nbsp;</font><b><font color="#000000">array</font></b>(<br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><b><font color="#000000">array</font></b>(<br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008000">&#8216;username&#8217;</font><font color="#008080">&nbsp;</font><font color="#000000">=&gt;</font><font color="#008080">&nbsp;</font><font color="#008000">&#8216;admin&#8217;</font><font color="#000000">,</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008000">&#8216;password&#8217;</font><font color="#008080">&nbsp;</font><font color="#000000">=&gt;</font><font color="#008080">&nbsp;</font><font color="#008000">&#8216;root&#8217;</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">),</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><b><font color="#000000">array</font></b>(<br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008000">&#8216;username&#8217;</font><font color="#008080">&nbsp;</font><font color="#000000">=&gt;</font><font color="#008080">&nbsp;</font><font color="#008000">&#8216;test&#8217;</font><font color="#000000">,</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008000">&#8216;password&#8217;</font><font color="#008080">&nbsp;</font><font color="#000000">=&gt;</font><font color="#008080">&nbsp;</font><font color="#008000">&#8216;test123&#8242;</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">),</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><b><font color="#000000">array</font></b>(<br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008000">&#8216;username&#8217;</font><font color="#008080">&nbsp;</font><font color="#000000">=&gt;</font><font color="#008080">&nbsp;</font><font color="#008000">&#8216;emran&#8217;</font><font color="#000000">,</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008000">&#8216;password&#8217;</font><font color="#008080">&nbsp;</font><font color="#000000">=&gt;</font><font color="#008080">&nbsp;</font><font color="#008000">&#8216;hasan&#8217;</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">)</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">);<br />
</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><i><font color="#FF8000">//&nbsp;Create&nbsp;the&nbsp;group&nbsp;array&nbsp;(this&nbsp;might&nbsp;also&nbsp;come&nbsp;from&nbsp;your&nbsp;db)</font></i><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#9D0000">$groupData</font><font color="#008080">&nbsp;</font><font color="#000000">=</font><font color="#008080">&nbsp;</font><b><font color="#000000">array</font></b>(<br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><b><font color="#000000">array</font></b>(<br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008000">&#8216;name&#8217;</font><font color="#008080">&nbsp;</font><font color="#000000">=&gt;</font><font color="#008080">&nbsp;</font><font color="#008000">&#8216;ADMIN&#8217;</font><font color="#000000">,</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008000">&#8216;users&#8217;</font><font color="#008080">&nbsp;</font><font color="#000000">=&gt;</font><font color="#008080">&nbsp;</font><b><font color="#000000">array</font></b>(<font color="#008000">&#8216;admin&#8217;</font><font color="#000000">,</font><font color="#008080">&nbsp;</font><font color="#008000">&#8216;emran&#8217;</font><font color="#000000">)</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">),</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><b><font color="#000000">array</font></b>(<br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008000">&#8216;name&#8217;</font><font color="#008080">&nbsp;</font><font color="#000000">=&gt;</font><font color="#008080">&nbsp;</font><font color="#008000">&#8216;QA&#8217;</font><font color="#000000">,</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008000">&#8216;users&#8217;</font><font color="#008080">&nbsp;</font><font color="#000000">=&gt;</font><font color="#008080">&nbsp;</font><b><font color="#000000">array</font></b>(<font color="#008000">&#8216;test&#8217;</font><font color="#000000">)</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">)</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">);<br />
</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><i><font color="#FF8000">//&nbsp;Define&nbsp;the&nbsp;root&nbsp;to&nbsp;the&nbsp;folders</font></i><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#9D0000">$rootDir</font><font color="#008080">&nbsp;</font><font color="#000000">=</font><font color="#008080">&nbsp;</font><font color="#9D0000">$_SERVER</font><font color="#000000">[</font><font color="#008000">'DOCUMENT_ROOT'</font><font color="#000000">]</font><font color="#008080">&nbsp;</font><font color="#000000">.</font><font color="#008080">&nbsp;</font><font color="#000000">DIRECTORY_SEPARATOR</font>;</p>
<p><font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><i><font color="#FF8000">//&nbsp;Protect&nbsp;them!</font></i><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#9D0000">$action</font><font color="#008080">&nbsp;</font><font color="#000000">=</font><font color="#008080">&nbsp;</font><font color="#9D0000">$this</font><font color="#000000">-&gt;</font>authhtpasswd-&gt;protect(<font color="#9D0000">$rootDir</font><font color="#008080">&nbsp;</font><font color="#000000">.</font><font color="#008080">&nbsp;</font><font color="#008000">&#8216;cs&#8217;</font><font color="#000000">,</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#9D0000">$rootDir</font><font color="#008080">&nbsp;</font><font color="#000000">.</font><font color="#008080">&nbsp;</font><font color="#008000">&#8216;data&#8217;</font><font color="#000000">,</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#9D0000">$userData</font><font color="#000000">,</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#9D0000">$groupData</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">);<br />
</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><i><font color="#FF8000">//&nbsp;Is&nbsp;there&nbsp;any&nbsp;error?&nbsp;If&nbsp;yes,&nbsp;then&nbsp;show&nbsp;them!</font></i><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><b><font color="#000000">if</font></b><font color="#008080">&nbsp;</font><font color="#000000">(!</font><font color="#9D0000">$action</font><font color="#000000">)</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">{</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#9D0000">$this</font><font color="#000000">-&gt;</font>authhtpasswd-&gt;printErrors();<br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}</font><br />
<font color="#008080">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}</font><br />
<font color="#000000">}</font><br />
<font color="#FF0000">?&gt;</font></font></font></font>
</div>
<p><strong>Md Emran Hasan</strong><br />
Co-founder &#038; CTO<br />
<a href="http://www.rightbrainsolution.com">Right Brain Solution Ltd.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2007/07/htpasswd-protection-library-for-code-igniter/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Code Igniter Rocks !</title>
		<link>http://phpfour.com/blog/2006/06/code-igniter-rocks/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=code-igniter-rocks</link>
		<comments>http://phpfour.com/blog/2006/06/code-igniter-rocks/#comments</comments>
		<pubDate>Fri, 09 Jun 2006 07:37:23 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Code Igniter]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/2006/06/09/code-igniter-rocks/</guid>
		<description><![CDATA[A few days back I discovered CakePHP and was very impressed with it. I started to code one of my apps with it but my impression decreased when i wanted to deploy it. After several methods and even communicating in their IRC, I wasnt able to deploy the app &#8211; total wastage of my time [...]]]></description>
			<content:encoded><![CDATA[<p><img alt="Code Igniter " title="Code Igniter " src="http://www.codeigniter.com/images/design/ci_logo2.gif" /></p>
<p>A few days back I discovered CakePHP and was very impressed with it. I started to code one of my apps with it but my impression decreased when i wanted to deploy it. After several methods and even communicating in their IRC, I wasnt able to deploy the app &#8211; total wastage of my time !!!</p>
<p>My search for a framework thats as easy (or easier ?) as Cake but having smooth deploy feature started again. I heard about Code Igniter before, but didnt give it much attention. Now I decided to visit their site. The one thing that forced me to give attention to it this time was this text on their site:</p>
<p><em>&#8220;If you&#8217;re a developer who lives in the real world of shared hosting accounts and  clients with deadlines, and if you&#8217;re tired of ponderously large and thoroughly undocumented frameworks that require rocket science to understand, Code Igniter might just be the right tool for you.&#8221;</em></p>
<p>I decided to test it out and to my surprise, they are not lying a bit ! I was able to create a site for one client in super-cool way in a lot lesser time than it would actually take without it. While coding the app, I loved CI&#8217;s simplicity, its non-geeky style framework functions and their simple usages, the top-notch documentation and a good user base for knowledge searching.</p>
<p>Now I know which framework I should use for my projects. Certainly Cake is more robust framework than CI, but CI beats it by its simplicity. And I also love that !</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2006/06/code-igniter-rocks/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: phpfour.com @ 2012-02-07 18:43:45 -->
