<?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>LAMP with ·dotmanila &#187; PHP</title>
	<atom:link href="http://dotmanila.com/blog/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://dotmanila.com/blog</link>
	<description>Linux Security, Apache Tuning, MySQL Optimization and PHP Programming</description>
	<lastBuildDate>Sun, 01 Aug 2010 01:54:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Internal Server Error (500) From Your PHP Application</title>
		<link>http://dotmanila.com/blog/2010/07/internal-server-error-500-from-your-php-application/</link>
		<comments>http://dotmanila.com/blog/2010/07/internal-server-error-500-from-your-php-application/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 03:29:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[http 500]]></category>
		<category><![CDATA[internal server error]]></category>
		<category><![CDATA[virtual server]]></category>

		<guid isPermaLink="false">http://dotmanila.com/blog/?p=136</guid>
		<description><![CDATA[virtual server, php, php-ldap, internal server error, http 500]]></description>
			<content:encoded><![CDATA[<p>Recently I was working on a script on a fresh virtual server. The script was pulled from a production server and was being actively used. When I try to run it on the test server, it was mysteriously not working, Apache access_log shows 500 HTTP response code, PHP <strong>log_errors</strong> is <strong>ON</strong>,even <strong>display_errors</strong> is set to <strong>ON</strong> but there were no errors being displayed or logged. Thoroughly deducing my .htaccess, Apache virtual host configuration and doing a sanity check on the application itself, the mysterious error was being caused by one PHP extension missing, in this case <strong>php-ldap</strong>.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">/var/www/sites/mediaweb</div>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://dotmanila.com/blog/2010/07/internal-server-error-500-from-your-php-application/&amp;n=Internal+Server+Error+%28500%29+From+Your+PHP+Application&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://dotmanila.com/blog/2010/07/internal-server-error-500-from-your-php-application/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://dotmanila.com/blog/2010/07/internal-server-error-500-from-your-php-application/&amp;title=Internal+Server+Error+%28500%29+From+Your+PHP+Application" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://dotmanila.com/blog/2010/07/internal-server-error-500-from-your-php-application/&amp;t=Internal+Server+Error+%28500%29+From+Your+PHP+Application" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Internal+Server+Error+%28500%29+From+Your+PHP+Application&amp;body=Link: http://dotmanila.com/blog/2010/07/internal-server-error-500-from-your-php-application/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A virtual%20server%2C%20php%2C%20php-ldap%2C%20internal%20server%20error%2C%20http%20500" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://dotmanila.com/blog/2010/07/internal-server-error-500-from-your-php-application/&amp;title=Internal+Server+Error+%28500%29+From+Your+PHP+Application" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://dotmanila.com/blog/2010/07/internal-server-error-500-from-your-php-application/&amp;title=Internal+Server+Error+%28500%29+From+Your+PHP+Application&amp;summary=virtual%20server%2C%20php%2C%20php-ldap%2C%20internal%20server%20error%2C%20http%20500&amp;source=LAMP with ·dotmanila" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://dotmanila.com/blog/2010/07/internal-server-error-500-from-your-php-application/&amp;title=Internal+Server+Error+%28500%29+From+Your+PHP+Application" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Internal+Server+Error+%28500%29+From+Your+PHP+Application+-+http://b2l.me/adk2m9&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://dotmanila.com/blog/2010/07/internal-server-error-500-from-your-php-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend_Validate_StringEquals</title>
		<link>http://dotmanila.com/blog/2010/01/zend_validate_stringequals/</link>
		<comments>http://dotmanila.com/blog/2010/01/zend_validate_stringequals/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 14:54:23 +0000</pubDate>
		<dc:creator>jervin</dc:creator>
				<category><![CDATA[Application Security]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ZendFramework]]></category>
		<category><![CDATA[Zend_Input_Filter]]></category>
		<category><![CDATA[Zend_Validate]]></category>

		<guid isPermaLink="false">http://dotmanila.com/blog/?p=121</guid>
		<description><![CDATA[If you ever wonder where that 'StringEquals' validator rule taken as example from the Zend_Filter_Input documentation page results in an error like below, well read again. It was clearly stated as 'hypothetical'. Plugin by name 'StringEquals' was not found in the registry; used paths: Zend_Validate_: Zend/Validate/ Given such validator would be useful on a number [...]]]></description>
			<content:encoded><![CDATA[<p>If you ever wonder where that 'StringEquals' validator rule taken as example from the Zend_Filter_Input documentation page results in an error like below, well read again. It was clearly stated as 'hypothetical'.</p>
<blockquote>
<h3>Plugin by name 'StringEquals' was not found in the registry; used paths: Zend_Validate_: Zend/Validate/</h3>
</blockquote>
<p>Given such validator would be useful on a number of situations i.e. confirming passwords, emails, etc. I present to you my own version of the class.</p>
<pre class="php"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">&lt;?php</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">class</span> Zend_Validate_StringEquals <span style="color: #000000; font-weight: bold;">extends</span> Zend_Validate_Abstract</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    const NOT_EQUAL	= <span style="color: #ff0000;">'stringNotEqual'</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    const MISSING	= <span style="color: #ff0000;">'stringMissing'</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #808080; font-style: italic;">/**</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    * @var array</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    protected <span style="color: #0000ff;">$_messageTemplates</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        self::<span style="color: #006600;">NOT_EQUAL</span>	=&gt; <span style="color: #ff0000;">&quot;%field1% and %field2% are not equal.&quot;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        self::<span style="color: #006600;">MISSING</span>	=&gt; <span style="color: #ff0000;">&quot;One or both strings are missing.&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #808080; font-style: italic;">/**</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    * @var array</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    protected <span style="color: #0000ff;">$_messageVariables</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">'field1'</span> =&gt; <span style="color: #ff0000;">'_field1'</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">'field2'</span> =&gt; <span style="color: #ff0000;">'_field2'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    protected <span style="color: #0000ff;">$_case</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    protected <span style="color: #0000ff;">$_field1</span> = <span style="color: #000000; font-weight: bold;">null</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    protected <span style="color: #0000ff;">$_field2</span> = <span style="color: #000000; font-weight: bold;">null</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #808080; font-style: italic;">/**</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    * Sets validator options</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    *</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    * @param  boolean $case</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    * @return void</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$case</span> = <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #0000ff;">$this</span>-&gt;_case = <span style="color: #0000ff;">$case</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #808080; font-style: italic;">/**</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    * Defined by Zend_Validate_Interface</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    *</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    * Returns true if and only if the the 2 strings are equal</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    *</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    * @param  array $value</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    * @return boolean</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> isValid<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    	<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/is_array"><span style="color: #000066;">is_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span> OR <a href="http://www.php.net/sizeof"><span style="color: #000066;">sizeof</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span> &lt; <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #0000ff;">$this</span>-&gt;_error<span style="color: #66cc66;">&#40;</span>self::<span style="color: #006600;">MISSING</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    	<span style="color: #0000ff;">$this</span>-&gt;_field1 = <a href="http://www.php.net/array_shift"><span style="color: #000066;">array_shift</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    	<span style="color: #0000ff;">$this</span>-&gt;_field2 = <a href="http://www.php.net/array_shift"><span style="color: #000066;">array_shift</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$this</span>-&gt;_case === <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span> <span style="color: #0000ff;">$function</span> = <span style="color: #ff0000;">'strcmp'</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #b1b100;">else</span> <span style="color: #0000ff;">$function</span> = <span style="color: #ff0000;">'strcasecmp'</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span> !== <span style="color: #0000ff;">$function</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$this</span>-&gt;_field1,<span style="color: #0000ff;">$this</span>-&gt;_field2<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #0000ff;">$this</span>-&gt;_error<span style="color: #66cc66;">&#40;</span>self::<span style="color: #006600;">NOT_EQUAL</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/count"><span style="color: #000066;">count</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$this</span>-&gt;_messages<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">false</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">true</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>Here is a sample test case. Validate password and confirm password elements represented by 'password' and 'cpassword' element names respectively.</p>
<pre class="php"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$filters</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'password'</span> =&gt; <span style="color: #ff0000;">'StringTrim'</span>, <span style="color: #ff0000;">'cpassword'</span> =&gt; <span style="color: #ff0000;">'StringTrim'</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$validators</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #ff0000;">'Password'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">'presence'</span> =&gt; <span style="color: #ff0000;">'required'</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'StringLength'</span>,<span style="color: #cc66cc;">5</span>,<span style="color: #cc66cc;">15</span><span style="color: #66cc66;">&#41;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">'fields'</span> =&gt; <span style="color: #ff0000;">'password'</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">'messages'</span> =&gt; <span style="color: #ff0000;">&quot;Passwords must be between 5 and 15 characters in length.&quot;</span><span style="color: #66cc66;">&#41;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #ff0000;">'Confirm password'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'StringEquals'</span><span style="color: #66cc66;">&#41;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">'fields'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'password'</span>,<span style="color: #ff0000;">'cpassword'</span><span style="color: #66cc66;">&#41;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">'messages'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #cc66cc;">0</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                Zend_Validate_StringEquals::<span style="color: #006600;">NOT_EQUAL</span> =&gt; <span style="color: #ff0000;">&quot;Passwords does not match.&quot;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                Zend_Validate_StringEquals::<span style="color: #006600;">MISSING</span> =&gt; <span style="color: #ff0000;">&quot;Both password fields must be filled.&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$inputdata</span> = <span style="color: #000000; font-weight: bold;">new</span> Zend_Filter_Input<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$filter</span>,<span style="color: #0000ff;">$validators</span>,<span style="color: #0000ff;">$_POST</span>,<span style="color: #0000ff;">$options</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://dotmanila.com/blog/2010/01/zend_validate_stringequals/&amp;n=Zend_Validate_StringEquals&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://dotmanila.com/blog/2010/01/zend_validate_stringequals/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://dotmanila.com/blog/2010/01/zend_validate_stringequals/&amp;title=Zend_Validate_StringEquals" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://dotmanila.com/blog/2010/01/zend_validate_stringequals/&amp;t=Zend_Validate_StringEquals" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Zend_Validate_StringEquals&amp;body=Link: http://dotmanila.com/blog/2010/01/zend_validate_stringequals/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A If%20you%20ever%20wonder%20where%20that%20%27StringEquals%27%20validator%20rule%20taken%20as%20example%20from%20the%20Zend_Filter_Input%20documentation%20page%20results%20in%20an%20error%20like%20below%2C%20well%20read%20again.%20It%20was%20clearly%20stated%20as%20%27hypothetical%27.%0D%0A%0D%0APlugin%20by%20name%20%27StringEquals%27%20was%20not%20found%20in%20the%20registry%3B%20used%20paths%3A%20Zend_Valida" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://dotmanila.com/blog/2010/01/zend_validate_stringequals/&amp;title=Zend_Validate_StringEquals" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://dotmanila.com/blog/2010/01/zend_validate_stringequals/&amp;title=Zend_Validate_StringEquals&amp;summary=If%20you%20ever%20wonder%20where%20that%20%27StringEquals%27%20validator%20rule%20taken%20as%20example%20from%20the%20Zend_Filter_Input%20documentation%20page%20results%20in%20an%20error%20like%20below%2C%20well%20read%20again.%20It%20was%20clearly%20stated%20as%20%27hypothetical%27.%0D%0A%0D%0APlugin%20by%20name%20%27StringEquals%27%20was%20not%20found%20in%20the%20registry%3B%20used%20paths%3A%20Zend_Valida&amp;source=LAMP with ·dotmanila" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://dotmanila.com/blog/2010/01/zend_validate_stringequals/&amp;title=Zend_Validate_StringEquals" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Zend_Validate_StringEquals+-+http://b2l.me/adk2nc&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://dotmanila.com/blog/2010/01/zend_validate_stringequals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FFMpeg-PHP: undefined symbol: php_gd_gdImageSetPixel</title>
		<link>http://dotmanila.com/blog/2009/10/ffmpeg-php-undefined-symbol-php_gd_gdimagesetpixel-86/</link>
		<comments>http://dotmanila.com/blog/2009/10/ffmpeg-php-undefined-symbol-php_gd_gdimagesetpixel-86/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 15:01:32 +0000</pubDate>
		<dc:creator>jervin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[ffmpeg-php]]></category>
		<category><![CDATA[php-gd]]></category>

		<guid isPermaLink="false">http://dotmanila.com/blog/?p=86</guid>
		<description><![CDATA[I was recently updating ffmpeg-php on one of our servers to the latest SVN release  of the 0.6.3 branch. On a 64bit CentOS 5.3 with PHP 5.2.11, the extension compiled and installed fine however Apache will not load it and spit out the error below: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ffmpeg.so' [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently updating ffmpeg-php on one of our servers to the latest SVN release  of the 0.6.3 branch. On a 64bit CentOS 5.3 with PHP 5.2.11, the extension compiled and installed fine however Apache will not load it and spit out the error below:</p>
<blockquote><p>PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ffmpeg.so' - /usr/lib64/php/modules/ffmpeg.so: undefined symbol: php_gd_gdImageSetPixel in Unknown on line 0</p></blockquote>
<p>Surely enough, the GD extension was there, but why is ffmpeg complaining about not finding that shared symbol? Because, ffmpeg is loading first than GD (alphabetically) and such symbol has not been loaded. After adding the GD extension line on top of ffmpeg making sure it loads first the error went away and all is well again.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://dotmanila.com/blog/2009/10/ffmpeg-php-undefined-symbol-php_gd_gdimagesetpixel-86/&amp;n=FFMpeg-PHP%3A+undefined+symbol%3A+php_gd_gdImageSetPixel&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://dotmanila.com/blog/2009/10/ffmpeg-php-undefined-symbol-php_gd_gdimagesetpixel-86/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://dotmanila.com/blog/2009/10/ffmpeg-php-undefined-symbol-php_gd_gdimagesetpixel-86/&amp;title=FFMpeg-PHP%3A+undefined+symbol%3A+php_gd_gdImageSetPixel" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://dotmanila.com/blog/2009/10/ffmpeg-php-undefined-symbol-php_gd_gdimagesetpixel-86/&amp;t=FFMpeg-PHP%3A+undefined+symbol%3A+php_gd_gdImageSetPixel" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=FFMpeg-PHP%3A+undefined+symbol%3A+php_gd_gdImageSetPixel&amp;body=Link: http://dotmanila.com/blog/2009/10/ffmpeg-php-undefined-symbol-php_gd_gdimagesetpixel-86/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A I%20was%20recently%20updating%20ffmpeg-php%20on%20one%20of%20our%20servers%20to%20the%20latest%20SVN%20release%C2%A0%20of%20the%200.6.3%20branch.%20On%20a%2064bit%20CentOS%205.3%20with%20PHP%205.2.11%2C%20the%20extension%20compiled%20and%20installed%20fine%20however%20Apache%20will%20not%20load%20it%20and%20spit%20out%20the%20error%20below%3A%0D%0APHP%20Warning%3A%C2%A0%20PHP%20Startup%3A%20Unable%20to%20load%20dynamic" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://dotmanila.com/blog/2009/10/ffmpeg-php-undefined-symbol-php_gd_gdimagesetpixel-86/&amp;title=FFMpeg-PHP%3A+undefined+symbol%3A+php_gd_gdImageSetPixel" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://dotmanila.com/blog/2009/10/ffmpeg-php-undefined-symbol-php_gd_gdimagesetpixel-86/&amp;title=FFMpeg-PHP%3A+undefined+symbol%3A+php_gd_gdImageSetPixel&amp;summary=I%20was%20recently%20updating%20ffmpeg-php%20on%20one%20of%20our%20servers%20to%20the%20latest%20SVN%20release%C2%A0%20of%20the%200.6.3%20branch.%20On%20a%2064bit%20CentOS%205.3%20with%20PHP%205.2.11%2C%20the%20extension%20compiled%20and%20installed%20fine%20however%20Apache%20will%20not%20load%20it%20and%20spit%20out%20the%20error%20below%3A%0D%0APHP%20Warning%3A%C2%A0%20PHP%20Startup%3A%20Unable%20to%20load%20dynamic&amp;source=LAMP with ·dotmanila" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://dotmanila.com/blog/2009/10/ffmpeg-php-undefined-symbol-php_gd_gdimagesetpixel-86/&amp;title=FFMpeg-PHP%3A+undefined+symbol%3A+php_gd_gdImageSetPixel" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=FFMpeg-PHP%3A+undefined+symbol%3A+php_gd_gdImageSetPixel+-+http://b2l.me/adk2nr&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://dotmanila.com/blog/2009/10/ffmpeg-php-undefined-symbol-php_gd_gdimagesetpixel-86/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>CodeIgniter and Smarty</title>
		<link>http://dotmanila.com/blog/2008/07/codeigniter-smarty/</link>
		<comments>http://dotmanila.com/blog/2008/07/codeigniter-smarty/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 11:08:34 +0000</pubDate>
		<dc:creator>jervin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[php framework]]></category>
		<category><![CDATA[smarty]]></category>

		<guid isPermaLink="false">http://dotmanila.com/blog/?p=21</guid>
		<description><![CDATA[I've been used to working on projects using Smarty, its flexibility and most of the HTML designers and graphics artists I have worked with are only familiar with it. Until recently I was compelled by my co-worker to use a framework and he started using CodeIgniter without our prior approval and knowledge. To save time, I have to deal with it and continue with the CI path. Fortunately, CI can be simply extended from its Models, Controllers, libraries even its core files so it was not a big deal tying Smarty and CI together. This is how we do it.]]></description>
			<content:encoded><![CDATA[<p>I've been used to working on projects using Smarty, its flexibility and most of the HTML designers and graphics artists I have worked with are only familiar with it. Until recently I was compelled by my co-worker to use a framework and he started using CodeIgniter without our prior approval and knowledge. To save time, I have to deal with it and continue with the CI path. Fortunately, CI can be simply extended from its Models, Controllers, libraries even its core files so it was not a big deal tying Smarty and CI together. This is how we do it.</p>
<p>According to the CI User Guide ->  Creating Libraries, you can create your own library or extend/replace an existing native CI library. So far we need to create our own and extend from Smarty. SO in our application folder we add our Smarty library like shown in the folder structure below:</p>
<pre>
+/system
|
+----/application
         |
         +----/libraries
                     |
                     +----/smarty
                     |        |
                     |        +----/internals
                     |        +----/plugins
                     |        +----/Config_File.class.php
                     |        +----/debug.tpl
                     |        +----/Smarty.class.php
                     |        +----/Smarty_Compile.class.php
                     +----/JHSmarty.php
                     +----/JHController.php
</pre>
<p>The above tree is only the part we are concerned, tying up Smarty with CI using libraries. You will notice two additional files, JHSmarty.php and JHController.php. Let us deal with JHSmarty.php first.</p>
<p>JHSmarty.php will serve as you CI custom library, it will extend the original Smarty class and we will add some additional functions for more flexibility. Consider the following example JHSmarty.php file.</p>
<pre>
<&#63;php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

require_once "smarty/Smarty.class.php";

class JHSmarty extends Smarty
{
    public $CI = null;

    public function __construct()
    {
	parent::Smarty();
    }

    public function view($resource_name, $cache_id = null)   {
	if (strpos($resource_name, '.') === false) {
            $resource_name .= '.tpl';
	}
        return parent::display($resource_name, $cache_id);
    }

    public public function register_ci()
    {
        $this->CI =&amp; get_instance();
    }
}
?>
</pre>
<p>Now to breakdown each component:</p>
<p><strong>__construct</strong> : As any PHP class we need a constructor, in this case we as well initialize our parent class by calling <code>parent::Smarty();</code>.</p>
<p><strong>view</strong> : This is a simple implementation of the <code>Smarty::display()</code> function wherein we can optinally pass only the name part of a template file without the ".tpl" extension. This can be useful if you are presenting static pages self contained on a template.</p>
<p><strong>register_ci</strong> : This function registers an instance of the CI base object into Smarty, meaning including all methods, variables and objects that you will normally find in your controller. Except in this case when you call the function the CI instance will be available as <code>i.e. $this->CI->load->model('Somemodel','somemodel');</code>. This is very useful if you are adding custom modifiers, plugins, etc to Smarty and you want to tap into existing resources in the CI object. Since smarty will pass itself to any plugin, modifier or outputfilter you can access it like this from any of them:</p>
<p><code>$smarty->CI->load->model('Somemodel','somemodel');</code></p>
<p>Also, you might want to autoload you JHSmarty library as you will be using your templating engine all through out your project. To automatically load your library just add the class name in all lowercase to your <code>/system/application/config/autoload.php</code></p>
<p><code>$autoload['libraries'] = array('jhsmarty');</code></p>
<p>So in your controller you can always reference your custom library as:</p>
<p><code>$this->jhsmarty</code></p>
<p>Now, let's go to the next file, JHController.php. The file is an extension of the native Controller class that comes with CI. Why would I need one? Simply because I need to control some aspects of my site on the Controller level i.e. Auth checking, loading global variables, etc.</p>
<p>One important note is, the JH prefix on the controller name (JH on the smarty library does not count I just used it for consistency). You must define your subclass prefix for CI to use them, <code>/system/application/config/config.php</code> contains the relative configuration.</p>
<p><code>$config['subclass_prefix'] = 'JH';</code></p>
<p>So what do I have on my extended Controller:</p>
<p><strong>The <code>defaultview</code> variable</strong> : Since my extended native controller will be used on all further controllers within my project, I can use this variable to assign the template I will be using to display the current request.</p>
<p><strong>The <code>finalize</code> method</strong> : This method will serve as my Smarty::display() version except that I can assign as much variables and control the further display of the <code>defaultview</code> variable. I can also trap errors and display an error page if needed.</p>
<p>I hope you find this article useful, mainly I wrote this for a new programmer I am working with. If you have any questions/comments feel free to drop a comment below.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://dotmanila.com/blog/2008/07/codeigniter-smarty/&amp;n=CodeIgniter+and+Smarty&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://dotmanila.com/blog/2008/07/codeigniter-smarty/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://dotmanila.com/blog/2008/07/codeigniter-smarty/&amp;title=CodeIgniter+and+Smarty" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://dotmanila.com/blog/2008/07/codeigniter-smarty/&amp;t=CodeIgniter+and+Smarty" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=CodeIgniter+and+Smarty&amp;body=Link: http://dotmanila.com/blog/2008/07/codeigniter-smarty/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A I%27ve%20been%20used%20to%20working%20on%20projects%20using%20Smarty%2C%20its%20flexibility%20and%20most%20of%20the%20HTML%20designers%20and%20graphics%20artists%20I%20have%20worked%20with%20are%20only%20familiar%20with%20it.%20Until%20recently%20I%20was%20compelled%20by%20my%20co-worker%20to%20use%20a%20framework%20and%20he%20started%20using%20CodeIgniter%20without%20our%20prior%20approval%20and%20knowledge.%20To%20save%20time%2C%20I%20have%20to%20deal%20with%20it%20and%20continue%20with%20the%20CI%20path.%20Fortunately%2C%20CI%20can%20be%20simply%20extended%20from%20its%20Models%2C%20Controllers%2C%20libraries%20even%20its%20core%20files%20so%20it%20was%20not%20a%20big%20deal%20tying%20Smarty%20and%20CI%20together.%20This%20is%20how%20we%20do%20it." rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://dotmanila.com/blog/2008/07/codeigniter-smarty/&amp;title=CodeIgniter+and+Smarty" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://dotmanila.com/blog/2008/07/codeigniter-smarty/&amp;title=CodeIgniter+and+Smarty&amp;summary=I%27ve%20been%20used%20to%20working%20on%20projects%20using%20Smarty%2C%20its%20flexibility%20and%20most%20of%20the%20HTML%20designers%20and%20graphics%20artists%20I%20have%20worked%20with%20are%20only%20familiar%20with%20it.%20Until%20recently%20I%20was%20compelled%20by%20my%20co-worker%20to%20use%20a%20framework%20and%20he%20started%20using%20CodeIgniter%20without%20our%20prior%20approval%20and%20knowledge.%20To%20save%20time%2C%20I%20have%20to%20deal%20with%20it%20and%20continue%20with%20the%20CI%20path.%20Fortunately%2C%20CI%20can%20be%20simply%20extended%20from%20its%20Models%2C%20Controllers%2C%20libraries%20even%20its%20core%20files%20so%20it%20was%20not%20a%20big%20deal%20tying%20Smarty%20and%20CI%20together.%20This%20is%20how%20we%20do%20it.&amp;source=LAMP with ·dotmanila" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://dotmanila.com/blog/2008/07/codeigniter-smarty/&amp;title=CodeIgniter+and+Smarty" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=CodeIgniter+and+Smarty+-+http://b2l.me/adytyk&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://dotmanila.com/blog/2008/07/codeigniter-smarty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
