<?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>Mahbubur Rahman - jQuery, PHP, JavaScript, Codeigniter, CSS &#187; Codeigniter</title>
	<atom:link href="http://www.mahbubblog.com/tag/codeigniter/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mahbubblog.com</link>
	<description>PHP, JQUERY, JAVASCRIPT fun</description>
	<lastBuildDate>Thu, 03 Jun 2010 07:23:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Form Validation Callbacks in HMVC in Codeigniter</title>
		<link>http://www.mahbubblog.com/php/form-validation-callbacks-in-hmvc-in-codeigniter/</link>
		<comments>http://www.mahbubblog.com/php/form-validation-callbacks-in-hmvc-in-codeigniter/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 09:13:57 +0000</pubDate>
		<dc:creator>Mahbub</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[callbacks]]></category>
		<category><![CDATA[form validation]]></category>
		<category><![CDATA[hmvc]]></category>

		<guid isPermaLink="false">http://www.mahbubblog.com/?p=190</guid>
		<description><![CDATA[Many of us are using the HMVC extension (Hierarchical Model View Controller) in codeigniter which is available. http://codeigniter.com/wiki/Modular_Extensions_-_HMVC HMVC helps developing modular apps in a very convenient way. All the things work simply fine just like a clean CI installation. There&#8217;re 1 or two exceptions which i have found. One is the callback of Form_validation [...]]]></description>
			<content:encoded><![CDATA[<p>Many of us are using the HMVC extension (Hierarchical Model View Controller) in codeigniter which is available. http://codeigniter.com/wiki/Modular_Extensions_-_HMVC</p>
<p>HMVC helps developing modular apps in a very convenient way. All the things work simply fine just like a clean CI installation. There&#8217;re 1 or two exceptions which i have found. One is the callback of Form_validation class. If we are making some forms like registration we check emails and usernames and we do it in the form validation class using callbacks. If we look at the basic callback structure when validating forms from CI documentation, it appears like.</p>
<pre class="brush: php">

&lt; ?php

class Form extends Controller
{

 function index()
 {
 $this-&gt;load-&gt;helper( array (

 &#039;form&#039;,
 &#039;url&#039;
 ) );

 $this-&gt;load-&gt;library( &#039;form_validation&#039; );

 $this-&gt;form_validation-&gt;set_rules( &#039;username&#039;, &#039;Username&#039;, &#039;callback_username_check&#039; );
 $this-&gt;form_validation-&gt;set_rules( &#039;password&#039;, &#039;Password&#039;, &#039;required&#039; );
 $this-&gt;form_validation-&gt;set_rules( &#039;passconf&#039;, &#039;Password Confirmation&#039;, &#039;required&#039; );
 $this-&gt;form_validation-&gt;set_rules( &#039;email&#039;, &#039;Email&#039;, &#039;required&#039; );

 if ($this-&gt;form_validation-&gt;run() == FALSE)
 {
 $this-&gt;load-&gt;view( &#039;myform&#039; );
 }
 else
 {
 $this-&gt;load-&gt;view( &#039;formsuccess&#039; );
 }
 }

 function username_check($str)
 {
 if ($str == &#039;test&#039;)
 {
 $this-&gt;form_validation-&gt;set_message( &#039;username_check&#039;, &#039;The %s field can not be the word &quot;test&quot;&#039; );
 return FALSE;
 }
 else
 {
 return TRUE;
 }
 }

}
?&gt;
</pre>
<p><span style="font-size: small;"><span style="font-family: verdana,geneva;"><span style="color: #143270; white-space: pre-wrap;">But this callback will not simply work. Some of my precious hours went why it was not working. Then i navigated the Form_validation.php in /system/libraries folder around line 580 which looks like </span></span></span></p>
<p><span style="font-size: small;"><span style="font-family: verdana,geneva;"><span style="color: #143270; white-space: pre-wrap;"><br />
</span></span></span></p>
<p><span style="color: #143270; font-family: 'Lucida Grande'; font-size: 14px; white-space: pre-wrap;"> </span></p>
<pre class="brush: php">
if ($callback === TRUE)
 {
 if ( ! method_exists($this-&gt;CI, $rule))
 {
 continue;
 }
</pre>
<p><span style="font-size: small;"><span style="color: #143270; font-family: 'Lucida Grande'; white-space: pre-wrap;"><span style="font-family: verdana,geneva;">The function &#8211; <strong>method_exists</strong> returns false even if the callback function is there in the Controller and after all in the CI loader object. So it came out from the forum that you have to do a little extension to Form Validation class which is </span></span></span></p>
<pre class="brush: php">
&lt; ?php if (!defined(&#039;BASEPATH&#039;)) exit(&#039;No direct script access allowed&#039;);

class MY_Form_validation extends CI_Form_validation
{
 function run($module = &#039;&#039;, $group = &#039;&#039;) {
 (is_object($module)) AND $this-&gt;CI =&amp; $module;
 return parent::run($group);
 }
}
/* End of file MY_Form_validation.php */
/* Location: ./application/libraries/MY_Form_validation.php */
</pre>
<p>And when running the validation like in earlier code</p>
<pre class="php"> if ($this-&gt;form_validation-&gt;run() == FALSE)</pre>
<p>you have to provide an addition $this as a parameter to run method. which will look like</p>
<pre class="php"> if ($this-&gt;form_validation-&gt;run(<strong>$this</strong>) == FALSE)</pre>
<p>Now, you validation callbacks will work perfectly.</p>
<p>Another note, if you&#8217;re trying to access a public variable of a controller via the get_instance() in hooks , you&#8217;ll have to write in your controller like this.</p>
<p>CI::instance()-&gt;var_name = &#8220;Some Value&#8221;;</p>
<p>May be there are some other required adjustments when using HMVC, but i came across this two time killing adjustments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mahbubblog.com/php/form-validation-callbacks-in-hmvc-in-codeigniter/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Is Kohana moving faster than Codeigniter ?</title>
		<link>http://www.mahbubblog.com/php/is-kohana-moving-faster-than-codeigniter/</link>
		<comments>http://www.mahbubblog.com/php/is-kohana-moving-faster-than-codeigniter/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 05:09:06 +0000</pubDate>
		<dc:creator>Mahbub</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[Kohana]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[alexa]]></category>
		<category><![CDATA[beyondcoding]]></category>
		<category><![CDATA[kohanaphp]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://www.mahbubblog.com/?p=127</guid>
		<description><![CDATA[Look at the Alexa graph above. What do u think ? &#160; I&#8217;ve been using Codeigniter in Mid and Fairly Big project for over a year and a half. Kohana was released before i started but the amount of online support and tutorials and an active company development (EllisLab) made me decide using CodeIgniter. But [...]]]></description>
			<content:encoded><![CDATA[<a href="http://www.mahbubblog.com/wp-content/uploads/2009/03/ci-vs-kohana.jpg"><img alt="Traffic Codeigniter VS KohanaPHP" title="ci-vs-kohana" width="470" height="300" class="size-full wp-image-128" src="http://www.mahbubblog.com/wp-content/uploads/2009/03/ci-vs-kohana.jpg" /></a>
<p>Look at the Alexa graph above. What do u think ? &nbsp;</p>
<p>I&#8217;ve been using Codeigniter in Mid and Fairly Big project for over a year and a half. Kohana was released before i started but the amount of online support and tutorials and an active company development (EllisLab) made me decide using CodeIgniter. But I keep checking updates on Kohana because it has lot of extra features over CI. It&#8217;s Strictly PHP5 OOP and has libraries like ORM which doesn&#8217;t exist CI&#8217;s distribution. Just out of curiosity, i went to Alexa and compared the traffic for CI and KohanaPHP and it really surprised me. Kohana is way ahead in terms of traffic. What does that mean? People are more involved with Kohana than CI ? Well, apparently YES. Kohana is community driven development. In CI, user contributes as addons to the Framework, which is ok. But when there&#8217;s an active driving force by the community, it&#8217;s better, at least i think.&nbsp;</p>
<p>Moreover I read some articles how to easily use Zend in Kohana in the beyondcoding.com. So that makes me think of leaning towards Kohana for my next projects.&nbsp;There are of course ways to use CI with Zend though but the integration method of Kohana with Zend looked neat.&nbsp;It won&#8217;t get much tough to switch to Kohana because it was originally based on CI. And default design pattern in Kohana is Factory (as it appears) while CI is singleton. Of course I&#8217;ll need to analyze some more benchmarks for scalability and other features before shifting focus.&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mahbubblog.com/php/is-kohana-moving-faster-than-codeigniter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
