<?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>Code Fury &#187; PHP Development</title>
	<atom:link href="http://codefury.net/category/php-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://codefury.net</link>
	<description>One programmer's formatted output stream</description>
	<lastBuildDate>Tue, 22 Jun 2010 23:36:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flushing CodeIgniter&#8217;s URI-based Cache (Part I)</title>
		<link>http://codefury.net/2009/12/flushing-codeigniters-uri-based-cache-part-i/</link>
		<comments>http://codefury.net/2009/12/flushing-codeigniters-uri-based-cache-part-i/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 04:49:33 +0000</pubDate>
		<dc:creator>Kenny Katzgrau</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://codefury.net/?p=152</guid>
		<description><![CDATA[CodeIgniter&#8217;s output caching mechanism &#8212; at least in my opinion &#8212; has limited usefulness. It can be used to cache the final payload sent to the user for a given number of minutes. But sometimes clearing the cache for all pages or a specific page can be useful, especially if keeping the user from seeing [...]]]></description>
			<content:encoded><![CDATA[<p>CodeIgniter&#8217;s output caching mechanism &#8212; at least in my opinion &#8212; has limited usefulness. It can be used to cache the final payload sent to the user for a given number of minutes. But sometimes clearing the cache for all pages or a specific page can be useful, especially if keeping the user from seeing stale data is important.</p>
<p>This post will discuss what caching is, and how it is used in CodeIgniter. The next post will provide a few helper methods for clearing caches for specific pages (or really, URIs). I think this will make CI&#8217;s caching feature a lot more usable.</p>
<p>In a nutshell, this is how (and why) output caching is typically implemented:</p>
<p>Suppose we have a page at http://mysite.com/stats/website which loads and shows all the statistics about the users on my site, activity, files posted, etc. In other words, a lot of SQL queries (maybe 40 or so) and calculations go into this page. That takes significant time and resources.</p>
<p>Now imagine that this page is particularly popular. Maybe a heavily-read blog or bookmarking service links to your website, and you receive an unexpected burst in traffic. All of those page loads are re-running your calculations and queries, and that is consuming serious memory and CPU cycles. The number of requests your website can serve per-minute is now falling through the floor!</p>
<p>The idea of caching involves using the fact that our page probably doesn&#8217;t need calculate those statistics or run those queries every time. Perhaps gathering all of that data once an hour would suffice.</p>
<p>&#8220;Caching&#8221; involves generating the statistics page like we normally would, but saving a copy of the output we were going to send to the user for a certain amount of time. During that time period, everyone who requests that page will get the same page output that we generated x minutes ago.</p>
<p>After that time period passes, and we receive another page request, we recalculate the stats, and send them to the user. Of course, we&#8217;ll save the newer stats for a given amount of time for subsequent requests.</p>
<p>This basic caching &#8212; &#8220;page caching&#8221; &#8212; is the kind that CodeIgniter offers.</p>
<p>When you are inside a controller, you can tell CodeIgniter that you want to cache any requests to the current URI for <strong>n</strong> minutes. For that time period, you only want to send the output your are about to generate.</p>
<p>This is how it looks:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Stats <span style="color: #000000; font-weight: bold;">extends</span> Controller
<span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">function</span> website<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// 40 SQL Queries (Maybe a little overboard)</span>
    <span style="color: #666666; font-style: italic;">// Serious, ultra-precise calculations</span>
    <span style="color: #666666; font-style: italic;">// More intensive code that isn't good for fast page loads</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Tell CI you want to cache the output of this page for 10 minutes.</span>
    <span style="color: #666666; font-style: italic;">// This means that for the next 10 minutes, when CodeIgniter receives</span>
    <span style="color: #666666; font-style: italic;">// a request for stats/website, the CI system will not even consult this</span>
    <span style="color: #666666; font-style: italic;">// method or instantiate this controller. It will serve a static page containing</span>
    <span style="color: #666666; font-style: italic;">// the exact content that you output here.</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cache</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'stats/website'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And that&#8217;s all you have to do! In this example, CodeIgniter&#8217;s output caching works great.</p>
<p>So then, what were the qualms I mentioned earlier?</p>
<p>Suppose we also cache user profile pages, which might be located at a URI similar to http://mysite.com/users/profile/kennyk. For whatever reason, we will assume that caching this page could be very beneficial due to heavy traffic on the site.</p>
<p>If a user profile is cached for 10 minutes, and a user updates his profile in some profile editing area, he will still see the older version of his profile page when he tries to view it. This can be confusing and inconvenient.</p>
<p>Other MVC frameworks (like Rails) handle this issue in a snap by allowing the developer to &#8220;sweep&#8221; caches at will. CodeIgniter does not offer any functionality similar to this.</p>
<p>My next post will document a cache helper I&#8217;ve whipped up to allow CodeIgniter to sweep caches for a given URI. Look out for &#8220;Flushing CodeIgniter&#8217;s URI-based Cache (Part II).&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://codefury.net/2009/12/flushing-codeigniters-uri-based-cache-part-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enable Site-Wide Profiling With CodeIgniter</title>
		<link>http://codefury.net/2009/11/enable-site-wide-profiling-with-codeigniter/</link>
		<comments>http://codefury.net/2009/11/enable-site-wide-profiling-with-codeigniter/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 18:35:10 +0000</pubDate>
		<dc:creator>Kenny Katzgrau</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[hooks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[profiling]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[wide]]></category>

		<guid isPermaLink="false">http://codefury.net/?p=121</guid>
		<description><![CDATA[A very cool part of CodeIgniter is its ability to give you the &#8216;profiling&#8217; information for page loads. That is, if you add:

$this-&#62;output-&#62;enable_profiler&#40;true&#41;;

In your controller before you load a view, CodeIgniter will give you information regarding how fast the page loaded, how many SQL queries executed, the content of each query, and the running time [...]]]></description>
			<content:encoded><![CDATA[<p>A very cool part of CodeIgniter is its ability to give you the &#8216;profiling&#8217; information for page loads. That is, if you add:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enable_profiler</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In your controller before you load a view, CodeIgniter will give you information regarding how fast the page loaded, how many SQL queries executed, the content of each query, and the running time of each query. This is incredibly useful when you are trying to debug your application, or simply see how quickly things are loading.</p>
<p>There&#8217;s only one problem: To enable profiling, that line of code above must be present. What if you want to profile several pages, or even your whole web application? In that case, you have to start thinking:</p>
<ul>
<li>I could put that line in the constructor of my controller, and then of of that controller&#8217;s methods will be profiled.</li>
<li>I could put that line in each method I want to profile.</li>
</ul>
<p>These methods start to get ugly. And of course, you don&#8217;t want to comment out each profiling line when you don&#8217;t need them.</p>
<p>My method to tackle this problem involves using CodeIgniter&#8217;s Hooks feature to enable or disable profiling for the entire web applications based on a value in the configuration file. In the end, I can turn on profiling for my entire website via a config value by setting it to true or false. This is my method:</p>
<p>1. Enable hooks in your CodeIgniter Application by going to config/config.php end setting the flag to true:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'enable_hooks'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span></pre></div></div>

<p>2. Create a file in the config directory named <strong>hooks.php</strong> if it does not already exist. Inside it, place:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$hook</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_controller_constructor'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                                <span style="color: #0000ff;">'class'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ProfilerEnabler'</span><span style="color: #339933;">,</span>
                                <span style="color: #0000ff;">'function'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'EnableProfiler'</span><span style="color: #339933;">,</span>
                                <span style="color: #0000ff;">'filename'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'hooks.classes.php'</span><span style="color: #339933;">,</span>
                                <span style="color: #0000ff;">'filepath'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'hooks'</span><span style="color: #339933;">,</span>
                                <span style="color: #0000ff;">'params'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
                                <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>3. Create a folder in your application directory named <strong>hooks </strong>(If it does not already exist). Inside it, create a file named <strong>hooks.classes.php</strong>. Inside it, put:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> ProfilerEnabler
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">function</span> EnableProfiler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$CI</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>get_instance<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$CI</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enable_profiler</span><span style="color: #009900;">&#40;</span> config_item<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'enable_profiling'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>4. Finally, add this line to your application&#8217;s main configuration file:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'enable_profiling'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span></pre></div></div>

<p>Setting this value to true will enable profiling across your entire website. Now, you can zip through pages, checking the load times of each without any trouble!</p>
<p>Note: I&#8217;ve always thought that an additional way to do this would be to extend the Controller class and enable profiling from there. But this method, I think, has the least impact on existing code.</p>
]]></content:encoded>
			<wfw:commentRss>http://codefury.net/2009/11/enable-site-wide-profiling-with-codeigniter/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>wpSearch 1.5.0.5 Released With Features, Fixes</title>
		<link>http://codefury.net/2008/08/wpsearch-1505-released-with-features-fixes/</link>
		<comments>http://codefury.net/2008/08/wpsearch-1505-released-with-features-fixes/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 05:09:52 +0000</pubDate>
		<dc:creator>Kenny Katzgrau</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Search Engine Development]]></category>
		<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[1.5.0.5]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wpsearch]]></category>

		<guid isPermaLink="false">http://codefury.net/?p=35</guid>
		<description><![CDATA[After an exhausting week and a half tracking down the source of a mysterious bug in wpSearch, I think I can finally close the book on the &#8220;null result&#8221; issue that had me pouring over the source code.
wpSearch 1.5.0.5, the first official release after the 1.5 landmark, brings to the forefront some of the features [...]]]></description>
			<content:encoded><![CDATA[<p>After an exhausting week and a half tracking down the source of a mysterious bug in wpSearch, I <strong>think </strong>I can finally close the book on the &#8220;null result&#8221; issue that had me pouring over the source code.</p>
<p>wpSearch 1.5.0.5, the first official release after the <a href="http://codefury.net/2008/07/wpsearch-15-the-fastest-lightest-yet/">1.5 landmark</a>, brings to the forefront some of the features and fixes slated in the last post. wpSearch 1.5 has had the following features implemented:</p>
<ul>
<li>Comment Searching</li>
<li>A behind-the-scenes event logger for easily figuring out user issues</li>
<li>An upgrade to the underlying Lucene Search</li>
<li>An upgrade to the underlying StandardAnalyzer (used for relevancy)</li>
</ul>
<p>And these fixes:</p>
<ul>
<li>No more null results after a post is edited</li>
<li>Foreign character support (or simply indexing content with &#8216;UTF-8&#8242; encoding</li>
<li>Memory issues for content-heavy posts</li>
</ul>
<p>wpSearch 1.5.0.5 is a rock-solid release that is starting to make a name for itself in the Wordpress world. The new &#8216;Phone Home&#8217; feature in wpSearch allows users to report their copy of wpSearch. A few of the blogs with wpSearch currently in use are listed here:</p>
<ul>
<li><a href="http://buildingtheergonomicguitar.com/">Building The Ergonomic Guitar</a></li>
<li><a href="http://www.computerbob.com/">ComputerBob</a></li>
<li><a href="http://savoringkentucky.com/wordpress">Savoring Kentucky</a></li>
</ul>
<p>Patrick Cushing at the <a href="http://EnterVenture.com">EnterVenture </a>blog wrote a very detailed comparision of the default Wordpress search&#8217;s relevancy vs. wpSearch&#8217;s. This article ended up at <a href="http://digg.com/software/wpSearch_could_be_the_WordPress_search_you_ve_been_waiting_f">digg</a>.</p>
<p>Of course, as far as wpSearch has come in its short lifespan, there exists a set of users that deserve credit for pointing out issues and keeping me informed of bugs, needed features, etc.. So, in no particular order, I would like to thank:</p>
<ul>
<li>ComputerBob, at <a href="http://ComputerBob.com">ComputerBob.com</a> for pointing out the first instance of the empty result issue. He has thoroughly documented his usage with wpSearch at his blog, in a fair and balanced fashion. Furthermore, he has sent his index data back with detailed comments when most users would simply give up on wpSearch. Thanks ComputerBob.</li>
<li><a href="http://buildingtheergonomicguitar.com/">Robert Irizarry</a>, who has kept the wpSearch thread at the Wordpress repository stuffed with feature ideas and issue notices.</li>
<li><a href="http://itsogay.com">Olivier</a>, who&#8217;s 6000 posts provided the first failed scalability test for wpSearch. His pointing out of this issue led to a change to allow for greater scalability &#8212; in other words, wpSearch 1.5 was tested successfully up to 7,000 posts. Great dedication to detailing these issues has helped wpSearch greatly.</li>
<li><a href="http://www.fellbeisser.net/news">Karl Heigl</a>, who first mentioned the fact the wpSearch was not handling German accents, and subsequently all foreign (to the U.S.) characters. This also ended up affecting Olivier. This bug was fixed in 1.5.0.5. Thanks Karl!</li>
<li>A user named Brian, said, &#8220;Thanks for the update.  If you need any other information or even help testing, I’d be happy to assist. Just let me know.  &#8221; Thanks for your support Brian.</li>
<li>And to all those who have donated to this project so far!</li>
</ul>
<p>So, wpSearch 1.5.0.5 wouldn&#8217;t be at it&#8217;s current status if it weren&#8217;t for those supporting it.</p>
<p>Features coming up for <a href="http://codefury.net/projects/wpSearch/">wpSearch</a> include result highlighting, contextual snippets, and a progress meter for index building.  I encourage everyone who is reading this but hasn&#8217;t installed wpSearch yet to try it out, and <a href="http://codefury.net/projects/wpsearch/wpsearch-screenshots/">see the awesome blog search that you&#8217;ve been missing.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://codefury.net/2008/08/wpsearch-1505-released-with-features-fixes/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>KLogger: A Simple Logging Class for PHP</title>
		<link>http://codefury.net/2008/07/klogger-a-simple-logging-class-for-php/</link>
		<comments>http://codefury.net/2008/07/klogger-a-simple-logging-class-for-php/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 03:09:21 +0000</pubDate>
		<dc:creator>Kenny Katzgrau</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[log]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[simple]]></category>

		<guid isPermaLink="false">http://codefury.net/?p=29</guid>
		<description><![CDATA[Since the latest release of wpSearch, a couple issues have cropped up and are slated to be fixed shortly. Some of the issues, although, are a bit harder to catch without a good set of debugging tools for PHP. The classic example of such a tool would be a log file logger.
As soon as I [...]]]></description>
			<content:encoded><![CDATA[<p>Since the latest release of wpSearch, a couple issues have cropped up and are slated to be fixed shortly. Some of the issues, although, are a bit harder to catch without a good set of debugging tools for PHP. The classic example of such a tool would be a log file logger.</p>
<p>As soon as I realized the need for a logger while developing wpSearch, I decided to check to see if one had already existed on the internet &#8212; someone had surely created a simple logging class and made it available before .. I would think. I&#8217;m a believer in the C programmer&#8217;s motto &#8220;build upon the work of others&#8221;, so checking to see if someone else has done the same thing prior to starting a project comes naturally.</p>
<p>After a little browsing, I couldn&#8217;t find what I was looking for. Put plainly, I wanted a logging class that:</p>
<ul>
<li>Checked permissions prior to logging</li>
<li>Had a priority heirarchy built in ( Debug, Info, Error, and Fatal Message Levels)</li>
<li>Logged to plain old text files</li>
<li>Managed file handling cleanly (Open the file once, close the file once)</li>
<li>Managed resources (make sure the file gets closed)</li>
</ul>
<p>Not too complicated. This logging class would require around 100 lines of code.</p>
<p>Another option involved using logging functions available in Zend, or the logging class provided in PEAR. These libraries were a little overkill for what I needed, so I passed.</p>
<p>I decided to write of the class myself, and it has turned out to be pretty handy. I figured someone else would probably find it useful as well, so I have posted it on it&#8217;s own project page. <a href="http://codefury.net/projects/klogger/">Click here to go to the KLogger project page</a>.</p>
<p>Using KLogger is very straight-forward. Here&#8217;s an example:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'KLogger.php'</span><span style="color: #339933;">;</span>
<span style="color: #339933;">...</span>
<span style="color: #000088;">$log</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> KLogger <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;log.txt&quot;</span> <span style="color: #339933;">,</span> KLogger<span style="color: #339933;">::</span><span style="color: #004000;">DEBUG</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Do database work that throws an exception</span>
<span style="color: #000088;">$log</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">LogError</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;An exception was thrown in ThisFunction()&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Print out some information</span>
<span style="color: #000088;">$log</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">LogInfo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Internal Query Time: <span style="color: #006699; font-weight: bold;">$time_ms</span> milliseconds&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Print out the value of some variables</span>
<span style="color: #000088;">$log</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">LogDebug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;User Count: <span style="color: #006699; font-weight: bold;">$User_Count</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Depending on the priority level that is used when instantiating a new KLogger, only certain messages are actually logged to the file. If the most verbose priority level is used, ( KLogger::DEBUG ), all messages are logged. If the least verbose level is used ( KLogger::FATAL ), only Fatal-level errors are logged. Here&#8217;s a breakdown of the most verbose level to the least-verbose level:</p>
<ul>
<li>Debug (Most Verbose)</li>
<li>Info &#8230;</li>
<li>Warn &#8230;</li>
<li>Error &#8230;</li>
<li>Fatal (Least Verbose)</li>
</ul>
<p>A sixth level is also available: KLogger::OFF, so if you need to release a site without logging, you can simply set the priority level to Off, and not have a single message logged. (In fact, a log file will never be opened).</p>
<p>There isn&#8217;t too much documentation on the class right now, but it shouldn&#8217;t be too hard to figure out.</p>
<p>A couple comments on design: A few log class examples I&#8217;ve seen implement a singleton pattern, essentially locking the programmer into using one logger at all times. I usually lean towards letting the developer decide those things: If he wants to use a single logger, he can create a global log object in his application.</p>
<h4>An screenshot of KLogger:</h4>
<p><a href="http://codefury.net/wp-content/uploads/2008/07/KLogger.jpg"><img style="border: 0pt none;" src="http://codefury.net/wp-content/uploads/2008/07/KLogger.jpg" alt="KLogger in Action" width="500" height="302" /></a></p>
<p>I think at this point I&#8217;ve actually done a better job describing KLogger in this post than on the project page. A few more details are listed there, along with the download. If you find it useful, leave a comment and let me know.</p>
<p><a href="http://codefury.net/projects/klogger/">Click here to go to the KLogger project page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://codefury.net/2008/07/klogger-a-simple-logging-class-for-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>wpSearch 1.5: The Fastest, Lightest Yet</title>
		<link>http://codefury.net/2008/07/wpsearch-15-the-fastest-lightest-yet/</link>
		<comments>http://codefury.net/2008/07/wpsearch-15-the-fastest-lightest-yet/#comments</comments>
		<pubDate>Sun, 20 Jul 2008 18:15:44 +0000</pubDate>
		<dc:creator>Kenny Katzgrau</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[lucene]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wpsearch]]></category>

		<guid isPermaLink="false">http://codefury.net/?p=27</guid>
		<description><![CDATA[After its first week in the wild, wpSearch has been run on a number of different versions of Wordpress and PHP, highlighting some places to improve aspects of its core. wpSearch 1.5 has just been released, with a completely rewritten search mechanism to bring search speeds into the milliseconds.
Certain features available in wpSearch 1.x.x.x have [...]]]></description>
			<content:encoded><![CDATA[<p>After its first week in the wild, wpSearch has been run on a number of different versions of Wordpress and PHP, highlighting some places to improve aspects of its core. wpSearch 1.5 has just been released, with a completely rewritten search mechanism to bring search speeds into the milliseconds.</p>
<p>Certain features available in wpSearch 1.x.x.x have been removed in favor of tighter integration with the Wordpress core and raw speed. The search popup is no longer an option, removing the need for 2 javascript libraries, 2 CSS files, and 4 images. This decreases the page load time by close to 500 ms for a first-time page view over a broadband connection.</p>
<p>wpSearch now integrates its results into the Wordpress search using pure Wordpress API. Here are some statistics from version 1.5:</p>
<table style="border: solid 1px #cccccc" border="0">
<tbody>
<tr>
<td><strong>Indexing Performance:</strong></td>
<td>~30 minutes for 6,000 posts (5 docs / sec)</td>
</tr>
<tr>
<td><strong>Typical Search Speed:</strong></td>
<td>30-100 ms over 1,000 posts</td>
</tr>
<tr>
<td><strong>&#8220;Atypical Search&#8221; Speed:</strong></td>
<td>400 ms over 1,000 duplicate posts with 1,000 matches</td>
</tr>
<tr>
<td><strong>Indexing Performance:</strong></td>
<td>~30 minutes for 6,000 posts</td>
</tr>
</tbody>
</table>
<p>These stats were gathered on a non-dedicated development server  with 1 GB Ram, 3.2 Ghtz Hyperthreaded Intel P4, with Windows XP, and a WAMP installation without any sort of code caching (like Zend Optimizer). Needless to say, this server isn&#8217;t the quickest, but it still turns out very impressive search times.</p>
<p>wpSearch 1.5 is also completely compatible with the latest release of Wordpress, 2.6.</p>
<p>Get it here: <a href="http://wordpress.org/extend/plugins/wpsearch/">http://wordpress.org/extend/plugins/wpsearch/</a></p>
<p>Keep the comments coming!</p>
<p>katzgrau@gmail.com</p>
]]></content:encoded>
			<wfw:commentRss>http://codefury.net/2008/07/wpsearch-15-the-fastest-lightest-yet/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>wpSearch Accepted Into Wordpress Plugins</title>
		<link>http://codefury.net/2008/07/wpsearch-accepted-into-wordpress-plugins-new-release/</link>
		<comments>http://codefury.net/2008/07/wpsearch-accepted-into-wordpress-plugins-new-release/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 05:43:04 +0000</pubDate>
		<dc:creator>Kenny Katzgrau</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Search Engine Development]]></category>
		<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[in]]></category>
		<category><![CDATA[lucene]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plug]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[repository]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://codefury.net/?p=25</guid>
		<description><![CDATA[wpSearch (more info in my previous post), the lucene-powered search plugin for Wordpress, has officially been accepted into the Wordpress plugins repository. You can view and download wpSearch here:
http://wordpress.org/extend/plugins/wpsearch/
The latest version as of right now is 1.1.0.0. Several major features have been added since the original beta release.

Seamless integration of wpSearch into your blog. After [...]]]></description>
			<content:encoded><![CDATA[<p>wpSearch (<a href="http://codefury.net/2008/06/a-lucene-based-search-plugin-for-wordpress/">more info in my previous post</a>), the lucene-powered search plugin for Wordpress, has officially been accepted into the Wordpress plugins repository. You can view and download wpSearch here:</p>
<p><a href="http://wordpress.org/extend/plugins/wpsearch/">http://wordpress.org/extend/plugins/wpsearch/</a></p>
<p>The latest version as of right now is 1.1.0.0. Several major features have been added since the original beta release.</p>
<ul>
<li>Seamless integration of wpSearch into your blog. After you activate wpSearch and build your blog&#8217;s search index, the search box on your blog will now be configured to use wpSearch for searches.</li>
<li>You can now decide whether you want search results in the page ( the standard ), or have them loaded into and AJAX search pop-up. (Originally, the AJAX pop-up was the only way to view results ). This option is configurable via the Wordpress admin screen.</li>
<li>Bloggers can now tweak the importance of things such as title, content, and tags in a blog search. This effectively allows control over what is considered relevant in a blog search.</li>
</ul>
<p>So what&#8217;s next for wpSearch?</p>
<p>More searchable content: It&#8217;s no secret that the best content on a blog is sometimes in the comments. This is especially true for bloggers of tech and programming sites where blog readers often put useful contributions in comments.</p>
<p>The opening of the source: At SourceForge! Sure, PHP is inherently open-source (it&#8217;s a scripting language, after all!). But the best future for wpSearch would entail its placement into SourceForge.NET where the coding community can have the opportunity to contribute to the wpSearch project.  wpSearch is already registered at SourceForge, and has a project page at:</p>
<p><a href="http://wpsearch.sourceforge.net/">http://wpsearch.sourceforge.net/</a>. (Right now, there isn&#8217;t much setup up).</p>
<p>I plan to have wpSearch developed at SourceForge, and have stable releases be uploaded to the plug-in repository at Wordpress.</p>
<p>There are some other features I plan to add to wpSearch very shortly, one of which is contextual search result content, so you can see the words around the matching content of a search result.</p>
<p>I can&#8217;t think of the others off the top of my head. What I would really like to know is if anyone finds wpSearch to be of value so far, and whether they are having any difficulties.</p>
<p>I read on another blog that blogs get xx% more comments if the words &#8220;Have your say&#8221; are at the end of a post. I think I&#8217;ll try that.</p>
<p>Have your say!</p>
]]></content:encoded>
			<wfw:commentRss>http://codefury.net/2008/07/wpsearch-accepted-into-wordpress-plugins-new-release/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A Lucene-based Search Plugin For Wordpress</title>
		<link>http://codefury.net/2008/06/a-lucene-based-search-plugin-for-wordpress/</link>
		<comments>http://codefury.net/2008/06/a-lucene-based-search-plugin-for-wordpress/#comments</comments>
		<pubDate>Tue, 01 Jul 2008 00:01:54 +0000</pubDate>
		<dc:creator>Kenny Katzgrau</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Search Engine Development]]></category>
		<category><![CDATA[php zend lucene wordpress search]]></category>

		<guid isPermaLink="false">http://codefury.net/?p=22</guid>
		<description><![CDATA[There are many things I love about Wordpress &#8212; the extendability, the ease of use, and large library of themes available online, to name a few. But if there is one aspect of Wordpress that needs a little work, it is the default search functionality.
Recently, I&#8217;ve been spending a lot of time working on a [...]]]></description>
			<content:encoded><![CDATA[<p>There are many things I love about Wordpress &#8212; the extendability, the ease of use, and large library of themes available online, to name a few. But if there is one aspect of Wordpress that needs a little work, it is the default search functionality.</p>
<p>Recently, I&#8217;ve been spending a lot of time working on a search plugin for Wordpress that is based on the Lucene search engine &#8212; a very cool and powerful search library used by <a href="http://www.manning.com/hatcher2/">a lot of big places</a>. The plugin is in its beta stage, and ready for use and evaluation by anyone who would like to check it out. The plugin is currently implemented on my blog, so you can use the search box on the upper-right side to see it in action.</p>
<p>wpSearch uses the PHP port of the library by Zend. It also spawned a sub-project, the PHP StandardAnalyzer.<a href="http://codefury.net/projects/StandardAnalyzer/"> You can read more about that here.</a></p>
<p>The search currently uses a lightbox floating over the page to allow users to navigate search results. An option to integrate the results into the page may be and option in the future.</p>
<p>The major features of wpSearch are:</p>
<ul>
<li>Unmatched and customizable search relevancy (that&#8217;s the power of Lucene working)</li>
<li>Very fast search speed</li>
<li>Wildcard and Boolean operator support</li>
<li>Easy installation</li>
<li>Instantly updated searching after a post has been written</li>
<li>Searching of Posts and Pages</li>
</ul>
<p>Features for advanced users:</p>
<ul>
<li>Customizable interface via CSS</li>
<li>Access to the internal search service for extendability</li>
</ul>
<p>wpSearch was written for a development contest at<a href="http://ltech.com"> LTech Consulting</a> (a firm specializing in search with Lucene and the Google Search Appliance), but with the full intent of being open source.  If anyone is interested in helping develop it, drop me a comment on this post.</p>
<p>Also, if anyone gives this plugin a try and has any suggestions, I would really appreciate your input! Just leave a comment and I&#8217;ll get back to you. The plugin will be made available in the Wordpress search repository shortly.</p>
<p>Full information about wpSearch (installation instructions, screenshots, etc) is available on <a href="http://codefury.net/projects/wpSearch/">wpSearch&#8217;s project page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://codefury.net/2008/06/a-lucene-based-search-plugin-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>A Stemming Analyzer for Zend&#8217;s PHP Lucene</title>
		<link>http://codefury.net/2008/06/a-stemming-analyzer-for-zends-php-lucene/</link>
		<comments>http://codefury.net/2008/06/a-stemming-analyzer-for-zends-php-lucene/#comments</comments>
		<pubDate>Thu, 05 Jun 2008 15:36:25 +0000</pubDate>
		<dc:creator>Kenny Katzgrau</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Search Engine Development]]></category>
		<category><![CDATA[php zend lucene search]]></category>

		<guid isPermaLink="false">http://katzgrau.simplesample.org/?p=10</guid>
		<description><![CDATA[In my last post I spoke a little about Zend&#8217;s Lucene implementation in PHP, and its extensive usefulness for content-oriented PHP web applications. One of the roadblocks to implementing a Google-like search, however, was the absence of a stemming analyzer in the Zend package.
While using PHP Lucene, I came across this issue while developing a [...]]]></description>
			<content:encoded><![CDATA[<p>In my last post I spoke a little about Zend&#8217;s Lucene implementation in PHP, and its extensive usefulness for content-oriented PHP web applications. One of the roadblocks to implementing a Google-like search, however, was the absence of a stemming analyzer in the Zend package.</p>
<p>While using PHP Lucene, I came across this issue while developing a plug-in for wordpress. I wasn&#8217;t getting the relevancy I needed in test searches that I was looking for, and I decided to develop one of my own. I decided that this analyzer should:</p>
<ul>
<li>Stem words for greater search relevancy</li>
<li>Use the pre-existing Zend lowercase filter</li>
<li>Filter out a standard set of stop words using the Zend stop words filter</li>
</ul>
<p>After a couple days working on the issue, I&#8217;ve developed an analyzer that performs these tasks. I&#8217;ve named it the &#8216;StandardAnalyzer&#8217; after the implementation Java&#8217;s Lucene has. You can download the <a href="/projects/StandardAnalyzer/">StandardAnalyzer at its project page</a>.</p>
<p>Just a few notes on the about its creation:</p>
<ul>
<li>It is not meant to sit within the Zend framework folder. The &#8216;StandardAnalyzer&#8217; should sit alongside it, and is configured accordingly. The reason for this is to keep what is Zend&#8217;s in Zend&#8217;s  folder, and what is the user&#8217;s in his own.  I figured that if the StandardAnalyzer was ever integrated into framework, the good folks at Zend would know best how they would like it.</li>
<li>The code provided handles English words only, but organized to encourage future languages as well.</li>
<li>I must give a special thanks to <a title="Richard Heyes" href="http://phpguru.net">Richard Heyes</a>, whose Stemming algorithm is used instead of my own. In tests, I found his code to be a bit more elegant and quicker than my own, which was a direct port of the Java stemming algorithm. From what I gather, Richard is a Zend-Certified Engineer, making his code usage very fitting.</li>
</ul>
<h4>Example Usage</h4>
<p>I&#8217;ve decided to pack the StandardAnalyzer with an example project and index to make things a little easier for those looking to use it. The <a href="/projects/StandardAnalyzer/">example project</a>, as well as most user projects, would start off like:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Zend/Search/Lucene.php'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'StandardAnalyzer/Analyzer/Standard/English.php'</span><span style="color: #339933;">;</span></pre></div></div>

<p>As mentioned before, the StandardAnalyzer folder should sit in the same directory as the Zend Framework.  Now that you have the power of Zend ready to go, you can proceed build your index. But don&#8217;t forget that to use the StandardAnalyzer, you have to set the default analyzer to an instance of the StandardAnalyzer. So before you index documents <strong>or</strong> search over the index, you should call:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">Zend_Search_Lucene_Analysis_Analyzer<span style="color: #339933;">::</span><span style="color: #004000;">setDefault</span>
<span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> StandardAnalyzer_Analyzer_Standard_English<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I folded that line to keep it looking readable.</p>
<p>Anyway, any indexing or searching you do after this line uses the Standard analyzer. (I may not have been very clear, but the same analyzer needs to be used when indexing and searching, or else you won&#8217;t get many results.) You can also change the getDefaultAnalyzer() code in Zend/Search/Lucene/Analysis/Analyzer to reference your the StandardAnalyzer too. But I would rather not change this code of the Framework, and leave it in untainted form.</p>
<p>So take a look at the <a href="/projects/StandardAnalyzer/">StandardAnalyzer project</a>, and the example project. The example was put together fairly quickly, but it should provide a good example of how to use it.  I think a synonym filter would make a nice addition in the future, so I might take a look into that.</p>
]]></content:encoded>
			<wfw:commentRss>http://codefury.net/2008/06/a-stemming-analyzer-for-zends-php-lucene/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>A word on Lucene&#8217;s PHP port by Zend</title>
		<link>http://codefury.net/2008/06/a-word-on-lucenes-php-port-by-zend/</link>
		<comments>http://codefury.net/2008/06/a-word-on-lucenes-php-port-by-zend/#comments</comments>
		<pubDate>Thu, 05 Jun 2008 04:12:21 +0000</pubDate>
		<dc:creator>Kenny Katzgrau</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Search Engine Development]]></category>
		<category><![CDATA[php development zend lucene]]></category>

		<guid isPermaLink="false">http://katzgrau.simplesample.org/?p=9</guid>
		<description><![CDATA[Lucene is an open source search engine written in Java. If you have never heard of it prior to now, listen to this: It allows you to create a mini google-like search for anything. That&#8217;s right &#8212; anything.
But I&#8217;ll be a little more specific: Consider you run a news website &#8212; or a wiki for [...]]]></description>
			<content:encoded><![CDATA[<p>Lucene is an open source search engine written in Java. If you have never heard of it prior to now, listen to this: It allows you to create a mini google-like search for anything. That&#8217;s right &#8212; anything.</p>
<p>But I&#8217;ll be a little more specific: Consider you run a news website &#8212; or a wiki for that matter. How would you let users search the website? For most programmers, the answer is in implementing a plain-vanilla SQL search over the title and content of the articles. There are a few issues with this approach:</p>
<ul>
<li>The search time can be fairly lengthy</li>
<li>Running a LIKE query can still be very inaccurate (a search for &#8216;manager&#8217; over a field containing &#8216;manage&#8217; will not be considered a match)</li>
<li>There is almost no relevancy relationship in the way the results are ordered</li>
</ul>
<p>Lucene is a Java package which lets a Java programmer insert documents into an &#8216;index&#8217;, basically the search engine&#8217;s data base, and search over that index later on. So it is a true search engine that a  Java programmer can use to grab information at incredible speeds: milliseconds in my tests.</p>
<p>The details of Lucene can be found at its <a title="Apache Incubator Site" href="http://lucene.apache.org/java/docs/index.html">Apache incubator Site</a>.</p>
<p>I&#8217;ll get to the real point of this post. Considering how useful a tool Lucene would be, you are probably somewhat disappointed that I said it was for Java. After all, many would find something like this most useful if integrated with a server-side language such as PHP.</p>
<p>Zend, a PHP devoted firm most noted for the <a title="Zend Framework" href="http://www.zend.com/en/community/framework">Zend Framework</a> created a &#8220;Search&#8221; component as part of its framework, which is a port of Lucene for PHP. Using this port can be extremely useful for implementing search functionality in a web application.  There is a single problem standing in the way of creating a true full text search, although, and that is the default search functionality provided in PHP Lucene.</p>
<p>Consider a scenario where we are employers searching for prospective employees on a job search board. In a certain applicant&#8217;s resume, he states that he has &#8220;Managed a software team with great success, and has great managerial skills.&#8221;</p>
<p>Let&#8217;s assume this guy&#8217;s resume, as well as thousands of other resumes are in a lucene search index. When an employer executes a search on the job board, the job board code than uses the Lucene API to find documents matching the manager&#8217;s search terms &#8220;sales manager&#8221;.</p>
<p>Using the standard functionality of PHP Lucene, our employer would likely never find our mentioned employee. Why? Because the word &#8216;managed&#8217; and &#8216;managerial&#8217; is not the word &#8216;manager&#8217;.  Even though this document is very relevant to the employer&#8217;s search, it will be nowhere within the result set.</p>
<p>Java Lucene has a way to overcome this scenario: the Standard Analyzer. The Standard analyzer is a component that Java Lucene can use to manipulate data when it is going into a search index. So when &#8220;Managed a software team with great success, and has great managerial skills&#8221; is put in the index, it will be stored as &#8220;manag a software team with great success, and has great manag skill.&#8221; The standard analyzer performs lower casing and word stemming on the data of a document.</p>
<p>The analyzer is also used on queries. &#8220;Sales manager&#8221; would become &#8220;sal manag&#8221;. Now a query of these terms would definitely turn up the employee we just spoke about.</p>
<p>PHP&#8217;s Lucene unfortunately does not have this ability yet. My next post will be about my  creation of such an analyzer for PHP Lucene.</p>
]]></content:encoded>
			<wfw:commentRss>http://codefury.net/2008/06/a-word-on-lucenes-php-port-by-zend/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
