<?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>Zend Framework Blog</title>
	<atom:link href="http://blog.richardknop.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.richardknop.com</link>
	<description>Zend Framework, PHP, Django, Python, SQL, MySQL, PostgreSQL, Oracle, PL/SQL, data model patterns, OOP, design patterns, JavaScript, jQuery, HTML, XHTML, CSS, XML, web services &#38; APIs, Security, E-commerce and much more</description>
	<lastBuildDate>Tue, 15 May 2012 23:13:51 +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>When there is a method to get an object, always use it!</title>
		<link>http://blog.richardknop.com/2012/05/when-there-is-a-method-to-get-an-object-always-use-it/</link>
		<comments>http://blog.richardknop.com/2012/05/when-there-is-a-method-to-get-an-object-always-use-it/#comments</comments>
		<pubDate>Tue, 15 May 2012 23:13:51 +0000</pubDate>
		<dc:creator>Richard Knop</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHPUnit]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Test_PHPUnit_ControllerTestCase]]></category>

		<guid isPermaLink="false">http://blog.richardknop.com/?p=762</guid>
		<description><![CDATA[I have just learned an important lesson. When using a framework (doesn&#8217;t matter if it&#8217;s Zend Framework, Symfony or anything else), always use a getter method of the controller object if available. There usually is a reason for why it exists. Simple example. I was writing some controller unit tests in Zend Framework extending Zend_Test_PHPUnit_ControllerTestCase. Inside [...]]]></description>
			<content:encoded><![CDATA[<p>I have just learned an important lesson. When using a framework (doesn&#8217;t matter if it&#8217;s Zend Framework, Symfony or anything else), always use a getter method of the controller object if available. There usually is a reason for why it exists. Simple example.</p>
<p>I was writing some controller unit tests in Zend Framework extending Zend_Test_PHPUnit_ControllerTestCase. Inside my controller I was creating a new instance of a request object like this:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="re1">$request</span> <span class="sy0">=</span> <span class="kw2">new</span> Zend_Controller_Request_Http<span class="sy0">;</span></div>
</li>
</ol>
</div>
<p>Instead of using the getter method:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="re1">$request</span> <span class="sy0">=</span> <span class="re1">$this</span><span class="sy0">-&gt;</span><span class="me1">getRequest</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
<p>The unit tests were failing and I did not understand why. The issue was that I was using an authentication controller plugin which checked for an authentication header and redirected request to a different controller action when the request did not have the correct header.</p>
<p>Of course, I had 100% coverage of the authentication plugin so I was sure the problem was inside the controller. It was simple &#8211; by creating a new instance of the request class, I was dropping any headers from the request. Therefor, all my controller tests were being redirected to a different action by the plugin, even the tests that were supposed to simulate a correctly authenticated request.</p>
<p>Using the getter method to get the request object solved the mysterious issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.richardknop.com/2012/05/when-there-is-a-method-to-get-an-object-always-use-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Removing all attributes from DOMNode in a foreach loop is not a good idea</title>
		<link>http://blog.richardknop.com/2012/05/removing-all-attributes-from-domnode-in-a-foreach-loop-is-not-a-good-idea/</link>
		<comments>http://blog.richardknop.com/2012/05/removing-all-attributes-from-domnode-in-a-foreach-loop-is-not-a-good-idea/#comments</comments>
		<pubDate>Tue, 15 May 2012 22:57:51 +0000</pubDate>
		<dc:creator>Richard Knop</dc:creator>
				<category><![CDATA[DOMDocument]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[DOMNode]]></category>

		<guid isPermaLink="false">http://blog.richardknop.com/?p=760</guid>
		<description><![CDATA[So few days ago in work I needed to remove all attributes from a DOMNode instance while parsing an XML response from a web service. Naively, I wrote a code like this: foreach &#40;$element-&#62;attributes as $attribute&#41; &#123; &#160; &#160; $element-&#62;removeAttribute&#40;$attribute-&#62;name&#41;; &#125; It turns out that the attributes collection is reindex each time you remove an [...]]]></description>
			<content:encoded><![CDATA[<p>So few days ago in work I needed to remove all attributes from a <a href="http://php.net/manual/en/class.domnode.php">DOMNode</a> instance while parsing an XML response from a web service. Naively, I wrote a code like this:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">foreach</span> <span class="br0">&#40;</span><span class="re1">$element</span><span class="sy0">-&gt;</span><span class="me1">attributes</span> <span class="kw1">as</span> <span class="re1">$attribute</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re1">$element</span><span class="sy0">-&gt;</span><span class="me1">removeAttribute</span><span class="br0">&#40;</span><span class="re1">$attribute</span><span class="sy0">-&gt;</span><span class="me1">name</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>It turns out that the attributes collection is reindex each time you remove an attribute. So the code above would delete only the first attribute in a case the node had 2 attributes, it would only remove first two attributes if the node had 4 attributes and so on.</p>
<p>The correct way to do this:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">while</span> <span class="br0">&#40;</span><span class="re1">$element</span><span class="sy0">-&gt;</span><span class="me1">attributes</span><span class="sy0">-&gt;</span><span class="me1">length</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re1">$element</span><span class="sy0">-&gt;</span><span class="me1">removeAttribute</span><span class="br0">&#40;</span><span class="re1">$element</span><span class="sy0">-&gt;</span><span class="me1">attributes</span><span class="sy0">-&gt;</span><span class="me1">item</span><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">-&gt;</span><span class="me1">name</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.richardknop.com/2012/05/removing-all-attributes-from-domnode-in-a-foreach-loop-is-not-a-good-idea/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Passing array of objects by reference is faster in PHP</title>
		<link>http://blog.richardknop.com/2012/03/passing-array-of-objects-by-reference-is-faster-in-php/</link>
		<comments>http://blog.richardknop.com/2012/03/passing-array-of-objects-by-reference-is-faster-in-php/#comments</comments>
		<pubDate>Sat, 03 Mar 2012 14:09:37 +0000</pubDate>
		<dc:creator>Richard Knop</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[benchmark]]></category>

		<guid isPermaLink="false">http://blog.richardknop.com/?p=755</guid>
		<description><![CDATA[I have decided to make a simple benchmark in order to prove what I have suspected for a long time &#8211; when you pass an array of objects by reference, it is faster than passing it by value. When you pass an array of objects without reference, PHP will have to create a new copy [...]]]></description>
			<content:encoded><![CDATA[<p>I have decided to make a simple benchmark in order to prove what I have suspected for a long time &#8211; when you pass an array of objects by reference, it is faster than passing it by value.</p>
<p>When you pass an array of objects without reference, PHP will have to create a new copy of the array which can be quite resources consuming, especially with arrays containing large objects. Here is my benchmark:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?php</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">class</span> Foo</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">private</span> <span class="re1">$bar</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">public</span> <span class="kw2">function</span> __construct<span class="br0">&#40;</span><span class="re1">$bar</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$this</span><span class="sy0">-&gt;</span><span class="me1">bar</span> <span class="sy0">=</span> <span class="re1">$bar</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">public</span> <span class="kw2">function</span> getBar<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re1">$this</span><span class="sy0">-&gt;</span><span class="me1">bar</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">public</span> <span class="kw2">function</span> setBar<span class="br0">&#40;</span><span class="re1">$bar</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$this</span><span class="sy0">-&gt;</span><span class="me1">bar</span> <span class="sy0">=</span> <span class="re1">$bar</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">public</span> <span class="kw3">static</span> <span class="kw2">function</span> reverseBars<span class="br0">&#40;</span><span class="kw3">array</span> <span class="re1">$foos</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">foreach</span> <span class="br0">&#40;</span><span class="re1">$foos</span> <span class="kw1">as</span> <span class="re1">$foo</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$foo</span><span class="sy0">-&gt;</span><span class="me1">setBar</span><span class="br0">&#40;</span><span class="kw3">strrev</span><span class="br0">&#40;</span><span class="re1">$foo</span><span class="sy0">-&gt;</span><span class="me1">getBar</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re1">$foos</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">public</span> <span class="kw3">static</span> <span class="kw2">function</span> reverseBarsByReference<span class="br0">&#40;</span><span class="kw3">array</span> <span class="sy0">&amp;</span><span class="re1">$foos</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">foreach</span> <span class="br0">&#40;</span><span class="re1">$foos</span> <span class="kw1">as</span> <span class="re1">$foo</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$foo</span><span class="sy0">-&gt;</span><span class="me1">setBar</span><span class="br0">&#40;</span><span class="kw3">strrev</span><span class="br0">&#40;</span><span class="re1">$foo</span><span class="sy0">-&gt;</span><span class="me1">getBar</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> test1<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re1">$foos</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="re1">$i</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="re1">$i</span> <span class="sy0">&lt;</span> <span class="nu0">10</span><span class="sy0">;</span> <span class="sy0">++</span><span class="re1">$i</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$foos</span><span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="kw2">new</span> Foo<span class="br0">&#40;</span><span class="st0">&#39;foo&#39;</span><span class="sy0">.</span><span class="re1">$i</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re1">$start</span> <span class="sy0">=</span> <span class="kw3">microtime</span><span class="br0">&#40;</span><span class="kw2">true</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re1">$foos</span> <span class="sy0">=</span> Foo<span class="sy0">::</span><span class="me2">reverseBars</span><span class="br0">&#40;</span><span class="re1">$foos</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re1">$end</span> <span class="sy0">=</span> <span class="kw3">microtime</span><span class="br0">&#40;</span><span class="kw2">true</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">return</span> <span class="re1">$end</span><span class="sy0">-</span><span class="re1">$start</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> test2<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re1">$foos</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="re1">$i</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="re1">$i</span> <span class="sy0">&lt;</span> <span class="nu0">10</span><span class="sy0">;</span> <span class="sy0">++</span><span class="re1">$i</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$foos</span><span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="kw2">new</span> Foo<span class="br0">&#40;</span><span class="st0">&#39;foo&#39;</span><span class="sy0">.</span><span class="re1">$i</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re1">$start</span> <span class="sy0">=</span> <span class="kw3">microtime</span><span class="br0">&#40;</span><span class="kw2">true</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Foo<span class="sy0">::</span><span class="me2">reverseBarsByReference</span><span class="br0">&#40;</span><span class="re1">$foos</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re1">$end</span> <span class="sy0">=</span> <span class="kw3">microtime</span><span class="br0">&#40;</span><span class="kw2">true</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">return</span> <span class="re1">$end</span><span class="sy0">-</span><span class="re1">$start</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$n</span> <span class="sy0">=</span> <span class="nu0">50000</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$times1</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">for</span> <span class="br0">&#40;</span><span class="re1">$i</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="re1">$i</span> <span class="sy0">&lt;</span> <span class="re1">$n</span><span class="sy0">;</span> <span class="sy0">++</span><span class="re1">$i</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re1">$times1</span><span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> test1<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$times2</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">for</span> <span class="br0">&#40;</span><span class="re1">$i</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="re1">$i</span> <span class="sy0">&lt;</span> <span class="re1">$n</span><span class="sy0">;</span> <span class="sy0">++</span><span class="re1">$i</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re1">$times2</span><span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> test2<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$withoutReference</span> <span class="sy0">=</span> <span class="kw3">array_sum</span><span class="br0">&#40;</span><span class="re1">$times1</span><span class="br0">&#41;</span><span class="sy0">/</span><span class="re1">$n</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$withReference</span> <span class="sy0">=</span> <span class="kw3">array_sum</span><span class="br0">&#40;</span><span class="re1">$times2</span><span class="br0">&#41;</span><span class="sy0">/</span><span class="re1">$n</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;Without reference: &#39;</span><span class="sy0">,</span> <span class="re1">$withoutReference</span><span class="sy0">,</span> <span class="st0">&#39;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0">&#39;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;With reference: &#39;</span><span class="sy0">,</span> <span class="re1">$withReference</span><span class="sy0">,</span> <span class="st0">&#39;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0">&#39;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$onePercent</span> <span class="sy0">=</span> <span class="re1">$withoutReference</span><span class="sy0">/</span><span class="nu0">100</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$percentFaster</span> <span class="sy0">=</span> <span class="nu0">100</span> <span class="sy0">-</span> <span class="re1">$withReference</span><span class="sy0">/</span><span class="re1">$onePercent</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;Without reference is &#39;</span><span class="sy0">,</span> <span class="re1">$percentFaster</span><span class="sy0">,</span> <span class="st0">&#39;% faster <img src='http://blog.richardknop.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> &#39;</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
<p>And the results:<br />
<a href="http://blog.richardknop.com/wp-content/uploads/2012/03/php-array-of-objects-reference-benchmark-results.png"><img class="aligncenter size-full wp-image-756" title="PHP array of objects reference benchmark results" src="http://blog.richardknop.com/wp-content/uploads/2012/03/Untitled.png" alt="" width="314" height="109" /></a></p>
<p>So it appears on average, passing arrays of objects by reference is 10% faster. What do yo think? Any objections to my benchmark?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.richardknop.com/2012/03/passing-array-of-objects-by-reference-is-faster-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A MySQL procedure to drop all tables in a specific database</title>
		<link>http://blog.richardknop.com/2012/02/a-mysql-procedure-to-drop-all-tables-in-a-specific-database/</link>
		<comments>http://blog.richardknop.com/2012/02/a-mysql-procedure-to-drop-all-tables-in-a-specific-database/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 19:47:10 +0000</pubDate>
		<dc:creator>Richard Knop</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[stored procedure]]></category>

		<guid isPermaLink="false">http://blog.richardknop.com/?p=753</guid>
		<description><![CDATA[Here is a nice MySQL stored procedure which can be used to delete all tables in a specified database. It takes one argument &#8211; a database name &#8211; and it deletes all tables in that database. Be careful when using this procedure DROP PROCEDURE IF EXISTS drop_all_tables_from_specified_database; DELIMITER $$ CREATE PROCEDURE drop_all_tables_from_specified_database(IN dbname CHAR(50)) BEGIN [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a nice MySQL stored procedure which can be used to delete all tables in a specified database. It takes one argument &#8211; a database name &#8211; and it deletes all tables in that database. Be careful when using this procedure <img src='http://blog.richardknop.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre>
DROP PROCEDURE IF EXISTS drop_all_tables_from_specified_database;

DELIMITER $$
CREATE PROCEDURE drop_all_tables_from_specified_database(IN dbname CHAR(50))
BEGIN
    DECLARE done INT DEFAULT FALSE;
    DECLARE tblname CHAR(50);
    DECLARE cur1 CURSOR FOR SELECT table_name FROM information_schema.tables WHERE table_schema = dbname COLLATE utf8_general_ci;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

    SET foreign_key_checks = 0;

    OPEN cur1;
    read_loop: LOOP
        FETCH cur1 INTO tblname;
        IF done THEN
            LEAVE read_loop;
        END IF;
        SET @database_name = dbname;
        SET @table_name = tblname;
        SET @sql_text = CONCAT('DROP TABLE ', @database_name, '.' , @table_name, ';');
        PREPARE stmt FROM @sql_text;
        EXECUTE stmt;
        DEALLOCATE PREPARE stmt;
    END LOOP;
    CLOSE cur1;

    SET foreign_key_checks = 1;

END$$
DELIMITER ;

CALL drop_all_tables_from_specified_database('test');

DROP PROCEDURE drop_all_tables_from_specified_database;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.richardknop.com/2012/02/a-mysql-procedure-to-drop-all-tables-in-a-specific-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install PHPUnit on FreeBSD 8.2</title>
		<link>http://blog.richardknop.com/2012/02/install-phpunit-on-freebsd-8-2/</link>
		<comments>http://blog.richardknop.com/2012/02/install-phpunit-on-freebsd-8-2/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 19:38:19 +0000</pubDate>
		<dc:creator>Richard Knop</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHPUnit]]></category>

		<guid isPermaLink="false">http://blog.richardknop.com/?p=746</guid>
		<description><![CDATA[Here is how to install PHPUnit on FreeBSD 8.2 so you can write unit tests for your code: #portsnap fetch #portsnap extract #portsnap update #cd /usr/ports/devel/pear #make #make install #pear channel-discover pear.symfony-project.com #pear install symfony/YAML #pear channel-discover pear.phpunit.de #pear install phpunit/PHPUnit #pear config-get php_dir The last line will show you the directory where PHPUnit was installed. Add [...]]]></description>
			<content:encoded><![CDATA[<p>Here is how to install PHPUnit on FreeBSD 8.2 so you can write unit tests for your code:</p>
<pre>#portsnap fetch
#portsnap extract
#portsnap update
#cd /usr/ports/devel/pear
#make
#make install

#pear channel-discover pear.symfony-project.com
#pear install symfony/YAML

#pear channel-discover pear.phpunit.de
#pear install phpunit/PHPUnit

#pear config-get php_dir</pre>
<p>The last line will show you the directory where PHPUnit was installed. Add it to your include path and you are ready to go:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="kw3">set_include_path</span><span class="br0">&#40;</span><span class="st0">&#39;/usr/local/share/pear&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">require_once</span><span class="br0">&#40;</span><span class="st0">&#39;PHPUnit/Autoload.php&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">class</span> FooTest <span class="kw2">extends</span> PHPUnit_Framework_TestCase</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.richardknop.com/2012/02/install-phpunit-on-freebsd-8-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MAMP 2.0.5 PHP PEAR not working</title>
		<link>http://blog.richardknop.com/2012/02/mamp-2-0-5-php-pear-not-working/</link>
		<comments>http://blog.richardknop.com/2012/02/mamp-2-0-5-php-pear-not-working/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 19:33:28 +0000</pubDate>
		<dc:creator>Richard Knop</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.richardknop.com/?p=743</guid>
		<description><![CDATA[After installing MAMP 2.0.5 on my Macbook I have found out PEAR doesn&#8217;t work (I wanted to use it to install PHPUnit for unit testing). This solves the problem: #rm /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf Once you delete that file PEAR will start working so you can install PHPUnit.]]></description>
			<content:encoded><![CDATA[<p>After installing MAMP 2.0.5 on my Macbook I have found out PEAR doesn&#8217;t work (I wanted to use it to install PHPUnit for unit testing). This solves the problem:</p>
<pre>#rm /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf</pre>
<p>Once you delete that file PEAR will start working so you can install PHPUnit.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.richardknop.com/2012/02/mamp-2-0-5-php-pear-not-working/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django missing admin CSS stylesheets</title>
		<link>http://blog.richardknop.com/2012/01/django-missing-admin-css-stylesheets/</link>
		<comments>http://blog.richardknop.com/2012/01/django-missing-admin-css-stylesheets/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 16:34:38 +0000</pubDate>
		<dc:creator>Richard Knop</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[WSGI]]></category>

		<guid isPermaLink="false">http://blog.richardknop.com/?p=733</guid>
		<description><![CDATA[Follow up on three of my previous posts: How to install and configure mod_wsgi on FreeBSD 8.2 How to install and configure Django with mod_wsgi on FreeBSD 8.2 Install PostgreSQL on FreeBSD 8.2 and make it work with Django I have been following the official Django tutorial and creating the polls app. I have decided [...]]]></description>
			<content:encoded><![CDATA[<p>Follow up on three of my previous posts:</p>
<ul>
<li><a href="http://blog.richardknop.com/2012/01/how-to-install-and-configure-mod_wsgi-on-freebsd-8-2/">How to install and configure mod_wsgi on FreeBSD 8.2</a></li>
<li><a href="http://blog.richardknop.com/2012/01/how-to-install-and-configure-django-with-mod_wsgi-on-freebsd-8-2/">How to install and configure Django with mod_wsgi on FreeBSD 8.2</a></li>
<li><a href="http://blog.richardknop.com/2012/01/install-postgresql-on-freebsd-8-2-and-make-it-work-with-django/">Install PostgreSQL on FreeBSD 8.2 and make it work with Django</a></li>
</ul>
<p>I have been following the official Django tutorial and creating the polls app. I have decided to test my app in a FreeBSD virtual machine with properly configured Apache instead of the development server though.</p>
<p>I got to the part where I am supposed to log in into the automatically generated admin area.  The http://IP_OF_MY_TEST_VM/admin/ works and I get the admin sign in page but the links to stylesheets are not working. It&#8217;s simple to fix that.</p>
<p>My app is located in /usr/local/www/myapp folder and it&#8217;s document root is set via httpd.conf to /usr/local/www/myapp/public directory. So:</p>
<pre>#cd /usr/local/www/myapp/public
#mkdir static
#cd static
#mkdir admin
#cp -r /usr/local/lib/python2.7/site-packages/django/contrib/admin/media/* /usr/local/www/myapp/public/static/admin</pre>
<p>That should copy free directories (css, img, js) into your document root. One more thing, edit your virtual host configuration to tell mod_wsgi to match /static/ to /usr/local/www/myapp/public/static/:</p>
<pre>WSGIPythonPath /usr/local/www
&lt;VirtualHost *:80&gt;
  ServerName localhost.home
  ServerAlias localhost.home

  DocumentRoot /usr/local/www/myapp/public
  Alias /static/ /usr/local/www/myapp/public/static/

  &lt;Directory /usr/local/www/myapp/public&gt;
  Order allow,deny
  Allow from all
  &lt;/Directory&gt;

  WSGIScriptAlias / /usr/local/www/myapp/wsgi.py

  &lt;Directory /usr/local/www&gt;
  Order allow,deny
  Allow from all
  &lt;/Directory&gt;
&lt;/VirtualHost&gt;</pre>
<p>Restart Apache:</p>
<pre>#/usr/local/sbin/apachectl restart</pre>
<p>And go to http://IP_OF_MY_TEST_VM/admin/. CSS stylesheets should now get loaded properly <img src='http://blog.richardknop.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.richardknop.com/2012/01/django-missing-admin-css-stylesheets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PostgreSQL chear sheet</title>
		<link>http://blog.richardknop.com/2012/01/postgresql-chear-sheet/</link>
		<comments>http://blog.richardknop.com/2012/01/postgresql-chear-sheet/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 15:02:34 +0000</pubDate>
		<dc:creator>Richard Knop</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[pgsql]]></category>
		<category><![CDATA[psql]]></category>

		<guid isPermaLink="false">http://blog.richardknop.com/?p=731</guid>
		<description><![CDATA[Since I have been using MySQL for a long time, transition to PostgreSQL is a little bit difficult. I will be posting some useful commands here for my own reference. This post will be getting updated a lot. I have explained how to install PostgreSQL on FreeBSD 8.2 in my previous post. To create a [...]]]></description>
			<content:encoded><![CDATA[<p>Since I have been using MySQL for a long time, transition to PostgreSQL is a little bit difficult. I will be posting some useful commands here for my own reference. This post will be getting updated a lot.</p>
<p>I have explained <a href="http://blog.richardknop.com/2012/01/install-postgresql-on-freebsd-8-2-and-make-it-work-with-django/">how to install PostgreSQL on FreeBSD 8.2</a> in my previous post.</p>
<p>To create a database:</p>
<pre>#su pgsql
$ createdb db_name
$ exit</pre>
<p>To drop a database:</p>
<pre>#su pgsql
$ dropdb db_name
$ exit</pre>
<p>To list all databases:</p>
<pre>#psql -l</pre>
<p>To open psql prompt for a database and a user:</p>
<pre>#psql db_name -U user</pre>
<h3>After opening psql prompt with psql db_name -U user</h3>
<p>To list all tables in a database:</p>
<pre>\d</pre>
<p>To describe  a table structure:</p>
<pre>\d table_name</pre>
<p>Psql help:</p>
<pre>\?</pre>
<p>To quit psql prompt:</p>
<pre>\q</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.richardknop.com/2012/01/postgresql-chear-sheet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install PostgreSQL on FreeBSD 8.2 and make it work with Django</title>
		<link>http://blog.richardknop.com/2012/01/install-postgresql-on-freebsd-8-2-and-make-it-work-with-django/</link>
		<comments>http://blog.richardknop.com/2012/01/install-postgresql-on-freebsd-8-2-and-make-it-work-with-django/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 02:43:09 +0000</pubDate>
		<dc:creator>Richard Knop</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[psycopg2]]></category>

		<guid isPermaLink="false">http://blog.richardknop.com/?p=724</guid>
		<description><![CDATA[Follow up on my previous two blog posts: How to install and configure mod_wsgi on FreeBSD 8.2 How to install and configure Django with mod_wsgi on FreeBSD 8.2 I am going to write down installation steps for PostgreSQL on FreeBSD 8.2 so it can be used with django.db.backends.postgresql_psycopg2 adapter. #cd /usr/ports/databases/postgresql91-server #make #make install Add [...]]]></description>
			<content:encoded><![CDATA[<p>Follow up on my previous two blog posts:</p>
<ul>
<li><a href="http://blog.richardknop.com/2012/01/how-to-install-and-configure-mod_wsgi-on-freebsd-8-2/">How to install and configure mod_wsgi on FreeBSD 8.2</a></li>
<li><a href="http://blog.richardknop.com/2012/01/how-to-install-and-configure-django-with-mod_wsgi-on-freebsd-8-2/">How to install and configure Django with mod_wsgi on FreeBSD 8.2</a></li>
</ul>
<p>I am going to write down installation steps for PostgreSQL on FreeBSD 8.2 so it can be used with django.db.backends.postgresql_psycopg2 adapter.</p>
<pre>#cd /usr/ports/databases/postgresql91-server
#make
#make install</pre>
<p>Add this line to /etc/rc.conf:</p>
<pre>postgresql_enable="YES"</pre>
<p>Next, initialize a PostgreSQL database cluster:</p>
<pre>#/usr/local/etc/rc.d/postgresql initdb</pre>
<p>Now add this line to /usr/local/pgsql/data/postgresql.conf:</p>
<pre>listen_addresses = '*'</pre>
<p>Thirdly, add this line to /usr/local/pgsql/data/pg_hba.conf:</p>
<pre>host   all   all   127.0.01/32 md5</pre>
<p>Reboot. Now let&#8217;s create a new user for our PostgreSQL database:</p>
<pre>#su pgsql
$ createuser -sdrP username
Enter password for new role: ******
Enter it again: ******

$ exit</pre>
<p>Finally, we need to install psycopg2 client in order to be able to connect to the PostgreSQL server from a Django web application.</p>
<pre>#pip install psycopg2
#/usr/local/sbin/apachectl restart</pre>
<p>Cool. Now you should be able to connect to the PostgreSQL server from your Django app. Make sure to create a database first:</p>
<pre>#su pgsql
$ createdb myapp
$ exit</pre>
<p>Now go to your Django application folder and edit settings.py. Use django.db.backends.postgresql_psycopg2 as ENGINE, also set NAME, USER and PASSWORD fields. Reload the Django app in the browser and it should work fine.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.richardknop.com/2012/01/install-postgresql-on-freebsd-8-2-and-make-it-work-with-django/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to install and configure Django with mod_wsgi on FreeBSD 8.2</title>
		<link>http://blog.richardknop.com/2012/01/how-to-install-and-configure-django-with-mod_wsgi-on-freebsd-8-2/</link>
		<comments>http://blog.richardknop.com/2012/01/how-to-install-and-configure-django-with-mod_wsgi-on-freebsd-8-2/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 20:55:20 +0000</pubDate>
		<dc:creator>Richard Knop</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[WSGI]]></category>

		<guid isPermaLink="false">http://blog.richardknop.com/?p=713</guid>
		<description><![CDATA[This is a follow up on my previous post: How to install and configure mod_wsgi on FreeBSD 8.2 I will assume you have followed all steps in the previous blog post and have FreeBSD 8.2 with Apache, Python and mod_wsgi installed and configured properly. We will use the same directory as we used for the [...]]]></description>
			<content:encoded><![CDATA[<p>This is a follow up on my previous post: <a href="http://blog.richardknop.com/2012/01/how-to-install-and-configure-mod_wsgi-on-freebsd-8-2/">How to install and configure mod_wsgi on FreeBSD 8.2</a></p>
<p>I will assume you have followed all steps in the previous blog post and have FreeBSD 8.2 with Apache, Python and mod_wsgi installed and configured properly. We will use the same directory as we used for the hello world python WSGI web app in the previous article. However, we will re-create it with Django so let&#8217;s delete if first:</p>
<pre>#rm -rf /user/local/www/myapp</pre>
<p>Let&#8217;s install Django:</p>
<pre>#cd /usr/ports/devel/py-pip
#make
#make install</pre>
<p>Either refresh your shell path or reboot your virtual machine and install Django via pip:</p>
<pre>#pip install django</pre>
<p>Test Django installation:</p>
<pre>#python
&gt;&gt;&gt;import django</pre>
<p>Next, I used UNIX find comman to find django-admin.py file:</p>
<pre>#find / -name django-admin.py
/usr/local/bin/django-admin.py
/usr/local/lib/python2.7/site-packages/django/bin/django-admin.py</pre>
<p>Let&#8217;s go to the /usr/local/www directory:</p>
<pre>#cd /usr/local/www</pre>
<p>And type:</p>
<pre>#/usr/local/bin/django-admin.py startproject myapp</pre>
<p>This will create a myapp directory with couple of files inside it, basically a standard Django project.</p>
<p>The only thing remaning is to configure mod_wsgi. First, edit the Apache configuration file:</p>
<pre>#ee /usr/local/etc/apache22/httpd.conf</pre>
<p>It should look exactly like the one in my previous blog post, the only thing changed is that I have moved the virtual host into a separate file. So delete the virtual host configuration and add an Include directive:</p>
<pre>Include /usr/local/www/myapp/httpd.conf</pre>
<p>I am basically telling the Apache to include contents of another httpd.conf file which will be inside the /usr/local/www/myapp folder. This way the virtual host configuration for our app will be inside the app home folder which makes way more sense. So create a new httpd.conf file:</p>
<pre>#cd /usr/local/www/myapp
#ee httpd.conf</pre>
<p>Configure an Apache virtual  host for our Django app:</p>
<pre>WSGIPythonPath /usr/local/www
&lt;VirtualHost *:80&gt;
  ServerName localhost.home
  ServerAlias localhost.home

  DocumentRoot /usr/local/www/myapp/public

  &lt;Directory /usr/local/www/myapp/public&gt;
  Order allow,deny
  Allow from all
  &lt;/Directory&gt;

  WSGIScriptAlias / /usr/local/www/myapp/wsgi.py

  &lt;Directory /usr/local/www&gt;
  Order allow,deny
  Allow from all
  &lt;/Directory&gt;
&lt;/VirtualHost&gt;</pre>
<p>Finally, you might have noticed that our Django app is missing the wsgi.py file mentioned in the httpd.conf. Let&#8217;s create it:</p>
<pre>#ee wsgi.py</pre>
<p>The simplest Django app will look like this:</p>
<pre>import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()</pre>
<p>That&#8217;s it. Open the app in your browser and you should see a page like this:</p>
<p style="text-align: center;"><a href="http://blog.richardknop.com/wp-content/uploads/2012/01/Screen-shot-2012-01-21-at-20.43.22.png"><img class="aligncenter  wp-image-719" title="Django project welcome page" src="http://blog.richardknop.com/wp-content/uploads/2012/01/Screen-shot-2012-01-21-at-20.43.22.png" alt="" width="508" height="120" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.richardknop.com/2012/01/how-to-install-and-configure-django-with-mod_wsgi-on-freebsd-8-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

