<?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; Tools</title>
	<atom:link href="http://codefury.net/category/tools/feed/" rel="self" type="application/rss+xml" />
	<link>http://codefury.net</link>
	<description>One programmer's formatted output stream</description>
	<lastBuildDate>Tue, 15 May 2012 15:03:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>The Top 10 CodeIgniter Sparks of 2011</title>
		<link>http://codefury.net/2011/12/top-10-codeigniter-sparks-of-2011/</link>
		<comments>http://codefury.net/2011/12/top-10-codeigniter-sparks-of-2011/#comments</comments>
		<pubDate>Sat, 31 Dec 2011 22:15:08 +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=487</guid>
		<description><![CDATA[John Crepezzi and I launched GetSparks.org (the CodeIgniter package manager and repository) a little under a year ago, and the response we received from the community was overwhelmingly positive. The best part of GetSparks isn&#8217;t the site itself. It&#8217;s a moderately simple app that provides a vehicle for quickly dropping other developers&#8217; code in your [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcodefury.net%2F2011%2F12%2Ftop-10-codeigniter-sparks-of-2011%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcodefury.net%2F2011%2F12%2Ftop-10-codeigniter-sparks-of-2011%2F&amp;source=_kennyk_&amp;style=normal&amp;space=12&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://seejohncode.com" target="_blank">John Crepezzi </a>and I launched <a href="http://getsparks.org">GetSparks.org</a> (the CodeIgniter package manager and repository) a little under a year ago, and the response we received from the community was overwhelmingly positive.</p>
<p>The best part of GetSparks isn&#8217;t the site itself. It&#8217;s a moderately simple app that provides a vehicle for quickly dropping other developers&#8217; code in your codebase.</p>
<p>Many of the packages on GetSparks are very well maintained. I am <strong>continually</strong> impressed by the amount of effort spark developers pour into their submissions when I peruse the site and try new packages out. One example would be <a href="http://wanwizard.eu/" target="_blank">WanWizard</a>&#8216;s <a title="DataMapper-ORM" href="http://getsparks.org/packages/DataMapper-ORM/versions/HEAD/show" target="_blank">DataMapper-ORM</a>: Look at how well thought out it is, and <a href="http://datamapper.wanwizard.eu/pages/requirements.html" target="_blank">how detailed the docs are</a>.</p>
<p>Another would be codeigniter-payments. I rolled in to the second day of CICon 2011 NYC to find @<a href="http://www.calvinfroedge.com" target="_blank">calvinfroedge</a> talking about a new payment spark he had made — <a href="http://getsparks.org/packages/codeigniter-payments/versions/HEAD/show" target="_blank">one of the most in-depth, flexible payment libs</a> I&#8217;ve ever seen.</p>
<p>GetSparks has almost clocked 50,000 package downloads at this point, but there are handful of sparks that have really stood out in terms of popularity. They are the year&#8217;s top 10:</p>
<table>
<tbody>
<tr>
<td>name</td>
<td>contributor</td>
<td>installs</td>
</tr>
<tr>
<td><a href="http://getsparks.org/packages/php-activerecord/versions/HEAD/show">php-activerecord</a></td>
<td>machuga</td>
<td>1806</td>
</tr>
<tr>
<td><a href="http://getsparks.org/packages/curl/versions/HEAD/show">curl</a></td>
<td>philsturgeon</td>
<td>1361</td>
</tr>
<tr>
<td><a href="http://getsparks.org/packages/template/versions/HEAD/show">template</a></td>
<td>philsturgeon</td>
<td>1010</td>
</tr>
<tr>
<td><a href="http://getsparks.org/packages/ion_auth/versions/HEAD/show">ion_auth</a></td>
<td>benedmunds</td>
<td>990</td>
</tr>
<tr>
<td><a href="http://getsparks.org/packages/restclient/versions/HEAD/show">restclient</a></td>
<td>philsturgeon</td>
<td>931</td>
</tr>
<tr>
<td><a href="http://getsparks.org/packages/DataMapper-ORM/versions/HEAD/show">DataMapper-ORM</a></td>
<td>WanWizard</td>
<td>748</td>
</tr>
<tr>
<td><a href="http://getsparks.org/packages/gravatar_helper/versions/HEAD/show">gravatar_helper</a></td>
<td>seejohnrun</td>
<td>688</td>
</tr>
<tr>
<td><a href="http://getsparks.org/packages/assets/versions/HEAD/show">assets</a></td>
<td>bstrahija</td>
<td>636</td>
</tr>
<tr>
<td><a href="http://getsparks.org/packages/fire_log/versions/HEAD/show">fire_log</a></td>
<td>dperrymorrow</td>
<td>623</td>
</tr>
<tr>
<td><a href="http://getsparks.org/packages/markdown/versions/HEAD/show">markdown</a></td>
<td>katzgrau</td>
<td>622</td>
</tr>
</tbody>
</table>
<p>And of course, there are people whose contributions have made GetSparks.org the success it is. A special thanks goes out to:</p>
<ul>
<li>Beau Frusetta — First team member (retired), and the guy who made GetSparks look halfway decent</li>
<li>Mike Pauley — Team member</li>
<li>Sean Downey — Team member</li>
<li>Joe Auty — Team member</li>
<li>Jake Ingman — Who made us a sweet logo</li>
<li>Joel Cox — For some fine features and great sparks</li>
<li>Balsamiq — Who donated a copy of their mockup software</li>
<li>Spicer Matthews of CloudManic, who contributed the &#8220;forking&#8221; feature (which I have big plans for)</li>
</ul>
<p>Happy New Year everyone. Keep up the awesome work, and keep knocking out those timeshanks when developing a new app with new sparks (things like payments, emailing, auth, assets, etc).</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://codefury.net/2011/12/top-10-codeigniter-sparks-of-2011/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>GetSparks.org Beta Released, Big Changes</title>
		<link>http://codefury.net/2011/05/getsparks-org-beta-released-big-changes/</link>
		<comments>http://codefury.net/2011/05/getsparks-org-beta-released-big-changes/#comments</comments>
		<pubDate>Fri, 06 May 2011 13:00:30 +0000</pubDate>
		<dc:creator>Kenny Katzgrau</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[packages]]></category>
		<category><![CDATA[respository]]></category>
		<category><![CDATA[sparks]]></category>

		<guid isPermaLink="false">http://codefury.net/?p=442</guid>
		<description><![CDATA[Note: CodeIgniter Reactor 2.0.2 has a bug in it&#8217;s core Loader class that breaks package config file loading (and sparks, sadly). It&#8217;s recommended that you use 2.0.1 OR the latest at https://bitbucket.org/ellislab/codeigniter-reactor OR make the following change in your 2.0.2 installation: https://bitbucket.org/ellislab/codeigniter-reactor/changeset/c461483c8ca0 . The last option is the best. It took a month longer than [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcodefury.net%2F2011%2F05%2Fgetsparks-org-beta-released-big-changes%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcodefury.net%2F2011%2F05%2Fgetsparks-org-beta-released-big-changes%2F&amp;source=_kennyk_&amp;style=normal&amp;space=12&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><strong>Note:</strong> <em>CodeIgniter Reactor 2.0.2 has a bug in it&#8217;s core Loader class that breaks package config file loading (and sparks, sadly). It&#8217;s recommended that you use 2.0.1 <strong>OR</strong> the latest at <a href="https://bitbucket.org/ellislab/codeigniter-reactor">https://bitbucket.org/ellislab/codeigniter-reactor</a> <strong>OR</strong> make the following change in your 2.0.2 installation: <a href="https://bitbucket.org/ellislab/codeigniter-reactor/changeset/c461483c8ca0">https://bitbucket.org/ellislab/codeigniter-reactor/changeset/c461483c8ca0</a> . The last option is the best.</em></p>
<p>It took a month longer than expected, but we&#8217;ve finally released the Beta version of <a href="http://getsparks.org">GetSparks.org</a>, the <a href="http://codefury.net/2011/03/introducing-codeigniter-sparks/">repository and package manager system for CodeIgniter</a>.</p>
<p>Here&#8217;s the very minimum of what you need to know:</p>
<ol>
<li>A spark.info file is now required in every spark</li>
<li>You should upgrade your spark system as soon as possible (just follow the usual installation instructions)</li>
<li>If you submitted a spark prior to the beta, we&#8217;ve normalized all version numbers to x.x.x. So curl 1.0 becomes curl 1.0.0. Check the site.</li>
</ol>
<p>The alpha was all about weeding out fundamental issues in the initial repo and system. The big problems we had were:</p>
<ul>
<li>Some spark developers wanted the ability to specify dependencies</li>
<li>There was no difference between a repository tag and the spark version — They had to be in sync</li>
<li>Users wanted RSS feeds for latest spark overall, and latest versions of individual sparks</li>
<li>There was no way to rate a spark</li>
<li>There was no way to tell if your spark was going to be accepted by the spark processor prior to submission</li>
</ul>
<p>We knocked those out and a little more with the beta. Going forward:</p>
<p>All sparks must have a spark.info file at the root. <a href="http://getsparks.org/spec-format">Details are here.</a></p>
<ul>
<li> You can now specify spark dependencies in spark.info</li>
<li> The spark manager will now install a spark and all of its dependencies</li>
<li> The spark manager can now self-update</li>
<li> All spark versions must be in x.x.x format. Sparks released prior to the beta had their version numbers change in the system (tags remained the same though)</li>
<li>Versions and tags are now decoupled. The version is pulled from spark.info</li>
<li>Sparks are now ratable via a simple &#8220;Love&#8221;, &#8220;Like&#8221;, or &#8220;Hate&#8221; rating</li>
<li><a href="http://getsparks.org/packages/spark-sdk/versions/HEAD/show">A Spark-SDK is available</a> to spark developers in order to validate their sparks prior to submission</li>
</ul>
<p><strong>It is necessary that you upgrade your spark manager with the release.</strong> The current version is 0.0.4. You can upgrade by removing the &#8216;tools&#8217; folder from your webroot and following the same installation instructions at: <a href="http://getsparks.org/install">http://getsparks.org/install</a></p>
<p>Send any issues to <a href="mailto:ohcrap@getsparks.org">ohcrap@getsparks.org</a>!</p>
<p>Now that the structural changes have been made, we can focus on tightening up the spark system&#8217;s feature set. This is what you see in the coming weeks:</p>
<ul>
<li>The ability to install sparks in configurations where the application folder is not in your webroot (possible now, but not automated)</li>
<li>The ability for sparks to act more like modules — ie, sparks will be able to override core libraries and more</li>
</ul>
<p>Also, we plan to:</p>
<ul>
<li>Put a news section on the site (long overdue)</li>
<li> Configure our notification system better so its emails don&#8217;t land in your spam folder</li>
</ul>
<p>And don&#8217;t forget the ultimate goal: <strong>Integration in CodeIgniter Reactor.</strong></p>
<p>Check out the beta and ping the team with any problems! ohcrap@getsparks.org</p>
]]></content:encoded>
			<wfw:commentRss>http://codefury.net/2011/05/getsparks-org-beta-released-big-changes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CodeIgniter/PHP + IIS + MySQL + MSSQL: It Works!</title>
		<link>http://codefury.net/2011/01/codeigniter-php-iis-mysql-mssql/</link>
		<comments>http://codefury.net/2011/01/codeigniter-php-iis-mysql-mssql/#comments</comments>
		<pubDate>Tue, 11 Jan 2011 13:41:48 +0000</pubDate>
		<dc:creator>Kenny Katzgrau</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sqlsrv]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://codefury.net/?p=316</guid>
		<description><![CDATA[There are a lot of people out there who call themselves &#8220;LAMP&#8221; developers — short for Linux, Apache, MySQL, PHP. That&#8217;s the standard configuration for production PHP applications. Recently, I ended up having to build a CodeIgniter application on Windows, IIS, Mysql+MS-SQL, and PHP. Sound like there are bound to be issues? You bet, and [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcodefury.net%2F2011%2F01%2Fcodeigniter-php-iis-mysql-mssql%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcodefury.net%2F2011%2F01%2Fcodeigniter-php-iis-mysql-mssql%2F&amp;source=_kennyk_&amp;style=normal&amp;space=12&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>There are a lot of people out there who call themselves &#8220;LAMP&#8221; developers — short for Linux, Apache, MySQL, PHP. That&#8217;s the standard configuration for production PHP applications. Recently, I ended up having to build a CodeIgniter application on <strong>W</strong>indows<strong>, I</strong>IS, Mysql+<strong>M</strong>S-SQL, and <strong>P</strong>HP. Sound like there are bound to be issues? You bet, and it especially hurts because now I&#8217;m a real-live WIMP developer.</p>
<p>And what made it even more interesting was that due to constraints, I had to develop the application in Ubuntu and deploy to Windows for production.</p>
<p>Please keep in mind that I didn&#8217;t opt for this setup by choice. The servers to be used were already in place, and well, it just had to be this way. I&#8217;d imagine this unholy mix can be found on server farms somewhere around the seventh or eighth circle of hell.</p>
<p><em><strong>Anyway, the point of this post is to document a few &#8220;gotchas&#8221; that came up along the way.</strong></em> At this point I should say that application is now happily humming along in production. I knew from the start that mixing all of the above would be a headache, but luckily, things worked out without sapping too much time. I should also say this before I start: Thanks to some great work done by others over the past 2 years, this setup was actually possible.</p>
<p><strong>Gotcha #1: PHP and MSSQL on Ubuntu</strong></p>
<p>Thank god this was so easy. In order to use the standard database functions like mssql_connect, mssql_query, etc, all I needed to do within my existing LAMP installation was run:</p>
<pre>$ sudo apt-get install php5-sybase</pre>
<p>And sh-bang, I could connect to SQL Server without an issue. From CodeIgniter, I set the database to use mssql as my driver, and I was home free.</p>
<p><strong>Gotcha #2: PHP and MSSQL on Windows</strong></p>
<p>For years, forums and IRC rooms were filled with hopeless requests to get these two to mix. In 2008, Microsoft wrote a driver to help PHP developers seamlessly connect to SQL Server. For Win-PHP installations, just install this gem:<a href="http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&amp;FamilyID=80e44913-24b4-4113-8807-caae6cf2ca05"> http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&amp;FamilyID=80e44913-24b4-4113-8807-caae6cf2ca05</a> . Also, read up on the docs.</p>
<p>That driver uses a different API then the regular PHP mssql_* functions. In fact, it uses sqlsrv_* functions instead. So CodeIgniter can&#8217;t work with it out of the box. Luckily I found an excellent 2 and 1/2 year-old post by a guy who wrote the CodeIgniter driver to work with the Microsoft drivers. Just download the code, and drop it into system/database/drivers. Read up here: <a href="http://www.kaweb.co.uk/blog/mssql-server-2005-and-codeigniter/">http://www.kaweb.co.uk/blog/mssql-server-2005-and-codeigniter/</a></p>
<p>One thing you will have to do to make it work with the latest version of CodeIgniter is create a dummy function in sqlsrv_driver.php. Just drop &#8216;function db_set_charset() { }&#8217; somewhere in the class declaration.</p>
<p><em>As a side note, that driver would make a great addition to <a href="http://codefury.net/2010/12/codeigniter-reactor/">CodeIgniter Reactor</a>.</em></p>
<p><strong>Gotcha #3: mssql vs. sqlsrv<br />
</strong></p>
<p>Notice that I had to use different drivers for connecting to SQL Server between Ubuntu and Windows. This is why it&#8217;s handy to use some sort of database abstraction class like the one that comes with CodeIgniter. All I had to do to switch between drivers when I deployed to the new environment was edit the configuration.</p>
<p>Also, query result fields that are fetched using PHP&#8217;s mssql driver come back as strings. The Windows sqlsrv driver gets fancy and hands back field values as objects. Your code won&#8217;t have to change for the most part, but beware that MSSQL &#8216;datetime&#8217; fields come back as native <a href="http://php.net/manual/en/class.datetime.php">PHP DateTime</a> objects using sqlsrv_*, not strings. In the code, I ended up doing something like: <em>if($date instanceof DateTime) return $date-&gt;format(&#8230;); else return $date;</em></p>
<p><em><strong>Edit: </strong>Commenter <a href="http://blogs.msdn.com/b/brian_swan">Brian Swan</a> and Twitter user <a href="http://www.juokaz.com/">Juozas Kaziukėnas</a> have pointed out that the sqlsrv_ PHP driver will take a boolean &#8216;ReturnDatesAsStrings&#8217; option in sqlsrv_connect() that specifies whether datetime fields come back as strings or objects. More info is here: <a href="http://msdn.microsoft.com/en-us/library/ee376928%28v=sql.90%29.aspx">http://msdn.microsoft.com/en-us/library/ee376928%28v=sql.90%29.aspx</a>. Thanks guys!</em></p>
<p><strong>Gotcha #4: File Permissions and Logging</strong></p>
<p>As the author of WPSearch, a Wordress search plugin which does heavy work with the filesystem, I can say that the number one cause of broken installations is that the permissions are too strict. On Windows, files can appear to be 777 when viewing them via FTP, but on the Windows end, they are set as &#8216;Read Only&#8217;, or &#8216;Archive&#8217;. This throws a serious wrench into things.</p>
<p>When I first deployed to the production server, all I would get for responses was a blank page. Worst of all, the log wasn&#8217;t writing anything. After a trace through the CodeIgniter bootstrap, I found that the application died when the logging class was loaded. If your application&#8217;s logging threshold is set to write anything, and the logging fails, the application might just crap-out. This is different behavior than I&#8217;ve seen on linux, where you just won&#8217;t see logs appear in the logging directory, but the overall application still works fine.</p>
<p>Just turn off logging to make sure that empty responses aren&#8217;t the result of file permission errors.</p>
<p><strong>Gotcha #5: No .htaccess Fo&#8217; You!</strong></p>
<p>I hadn&#8217;t known that I needed to drop the final application into an IIS instance from the start. I learned about that 1 day prior to the launch. Before that, I though I&#8217;d be rollin&#8217; on Windows/Apache. Wrong!</p>
<p>IIS doesn&#8217;t use silly .htaccess files, which I had only used for standard URL rewriting/prettified URLs. I was forced to decide between converting the .htaccess to an IIS web.config file, or just ditch the prettified URLs. Since it was a small application, I went with the latter. Here&#8217;s a nice StackOverflow thread discussing a translation though: <a href="http://stackoverflow.com/questions/702526/translating-an-apache-htaccess-file-to-an-iis-web-config">http://stackoverflow.com/questions/702526/translating-an-apache-htaccess-file-to-an-iis-web-config</a></p>
<p><em><strong>Edit:</strong> Juozas had some comments here too: &#8220;@_kennyk_  about .htaccess vs web.config &#8211; you can actually import .htaccess in IIS URL Rewrite section.&#8221;</em></p>
<p><strong>Gotcha #6: 2 Databases, 1 Application</strong></p>
<p>This is more of a CodeIgniter issue. For this application I had to lookup data in a MySQL database, then use some of that information to pull rows from a MSSQL database. The hurdle revolves around having two concurrent database connections open in CodeIgniter.</p>
<p>You can&#8217;t really load the database in traditional CodeIgniter style, like $this-&gt;load-&gt;database(), or by autoloading it. Something like this doesn&#8217;t work:</p>
<pre>$this-&gt;load-&gt;database('mysql-group-name');
# Do Stuff with mysql
$this-&gt;load-&gt;database('mssql-group-name');
# Do Stuff with mssql</pre>
<p>Instead, you have to ask CodeIgniter to hand you back the actual database object with each connection. It&#8217;s a good idea to encapsulate each within the models where you&#8217;re using them. Do something like this:</p>
<pre>class SomeMySQLModel extends Model {
  # the mysql db instance
  private $_db = NULL;

  function SomeMySQLModel() {
    $this-&gt;_db = $this-&gt;load-&gt;database('mysql-group', TRUE);
  }
}</pre>
<pre>class SomeMSSQLModel extends Model {
   # the mssql db instance
   private $_db = NULL;

   function SomeMSSQLModel() {
     $this-&gt;_db = $this-&gt;load-&gt;database('mssql-group', TRUE);
   }
 }</pre>
<p><strong>Gotcha #7: Mysterious lag time</strong></p>
<p>IIS can exhibit some odd behavior regarding response times. When I was initially testing the application on my SliceHost dev server, I was getting pretty speedy responses in about ~100ms (keep in mind that I was connecting to both MSSQL and MySQL across the internet, not locally).</p>
<p>But when I moved to production, requests were taking 6 seconds each. Confused, I thought there must be some sort of bottleneck in the application. I used CodeIgniter&#8217;s profiling and benchmarking classes to investigate. I benchmarked the MySQL and MSSQL connections, queries, and overall application execution time.</p>
<p>The app was reporting that it was finishing responses within 100ms. So where was this strange delay coming from?</p>
<p>I then thought there might be some sort of redirect loop going on. From the shell, I ran:</p>
<pre>$ time curl -v [address]</pre>
<p>And something else became apparent. The full content of the page would come back, but there was a 6 second lag before the connection would finally close. After a little research on the Google, it turns out I&#8217;m not the only one who&#8217;s observed this with PHP and IIS: <a href="http://www.google.com/search?q=iis+php+response+lag">http://www.google.com/search?q=iis+php+response+lag</a></p>
<p>I would like to say I figured out why IIS was being so lame, but the in-house net-admin suggested moving the application to another production server on hand, where the issue mysteriously dissappeared. At that point, everyone was happy, so I didn&#8217;t look into it any further. I <em>did</em> read about some resolutions regarding DNS settings, and skipping name resolutions in the db configurations. That might have been it, but I&#8217;ll never know.</p>
<p><strong>Recap:</strong></p>
<p>Don&#8217;t willingly try this. That being said, everything worked out much better than it could have, and there were relatively easy solutions to the bumps along the way. If you have to put together a project like this, I highly suggest using some sort of database abstraction (or a framework like CodeIgniter), and planning out how you&#8217;ll work out URLs, permissions, and differing environments. Thinking these things over will save you a lot of time, and hopefully leave the stakeholders a whole lot happier.</p>
]]></content:encoded>
			<wfw:commentRss>http://codefury.net/2011/01/codeigniter-php-iis-mysql-mssql/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>CodeIgniter Reactor? What’s Going On?</title>
		<link>http://codefury.net/2010/12/codeigniter-reactor/</link>
		<comments>http://codefury.net/2010/12/codeigniter-reactor/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 02:31:05 +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=296</guid>
		<description><![CDATA[A couple of weeks ago, Derek Jones of EllisLabs announced that the CodeIgniter Core would officially be branched so a community-driven version of the framework could be created. This new branch will be called CodeIgniter Reactor. The plan, which was clarified today, is focused on allowing a select group of CI engineers to actively commit [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcodefury.net%2F2010%2F12%2Fcodeigniter-reactor%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcodefury.net%2F2010%2F12%2Fcodeigniter-reactor%2F&amp;source=_kennyk_&amp;style=normal&amp;space=12&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>A couple of weeks ago, <a href="http://ellislab.com/company/team/derek_jones/">Derek Jones of EllisLabs</a> announced that the <a href="http://codeigniter.com">CodeIgniter</a> Core would officially be branched so a community-driven version of the framework could be created. This new branch will be called <em>CodeIgniter Reactor</em>.</p>
<p>The plan, <a href="http://codeigniter.com/news/codeigniter_in_2011_reactor_core_uservoice/">which was clarified today</a>, is focused on allowing a select group of CI engineers to actively commit new features to the codebase, while taking feature requests via a uservoice forum. Over time, any proven, time-tested features in Reactor will be merged into the Core.</p>
<p>This announcement comes after a two year period of relatively few changes to CodeIgniter — something the community has had mixed feelings about. For some, it meant CodeIgniter would remain a remarkably stable platform to build on in contrast to frameworks like Cake or Kohana. For others, it meant CodeIgniter was probably dead.</p>
<p><strong>So is that why frameworks like Kohana, once a fork of CodeIgniter, exist?</strong></p>
<p>That, and also: A frustrating reality for many in the CodeIgniter community is that although it is the fastest, lightest MVC framework for PHP, it still lacks some important features. Many once-smitten CodeIgniter evangelists grew out of the framework and began looking for something that was more full featured. That is, they wanted an ORM, more libraries, more robust implementations of unit testing and caching, and a style of usage that actually conforms to the definition of MVC.</p>
<p><strong>Why does CodeIgniter still have such a loyal following if more full-featured frameworks are around?</strong></p>
<p>As mentioned, CodeIgniter is considered one of the fastest script-based frameworks available. It takes a “load only what you need” approach — something other platforms definitely don’t do. <a href="http://toys.lerdorf.com/">Rasmus Ledorf</a>, the original author of PHP and skeptic of PHP frameworks in general, has even singled out the framework as something he might actually use.</p>
<p><em>As a side note, while at Yahoo! I’ve had the chance to read into exactly why Rasmus doesn’t like MVC via the internal wiki pages that he wrote himself — and guess what, he’s right. But that’s a topic for another post.</em></p>
<p>The other big (if not <em>HUGE</em>) reason that CodeIgniter has remained popular is the documentation. You cannot find a framework with more clear or concise documentation. Of course, it’s easy to keep the docs current when the framework hasn’t changed for two years!</p>
<p><strong>So what the hell is going to happen with CodeIgniter Reactor?</strong></p>
<p>I’m one of the engineers on the project, and I’ll be clear that CodeIgniter Reactor <em>will</em> pick up where CodeIgniter left off. Although the official roadmap hasn’t been laid out just yet, you’ll find Reactor will still have a high level of dependability and outstanding documentation. <em>If Reactor’s docs fall into dismay, hold me personally responsible. I won’t let it happen.</em></p>
<p>There is a feature request forum for Reactor set up at <a href="http://codeigniter.uservoice.com/">UserVoice</a> — a place where CI users who want to suggest additions can go.</p>
<p>Of course, that doesn’t mean every feature suggestion, whether it’s the popular or not should actually be implemented. The Reactor team will make intelligent decisions about what and what not to change, remaining in line with the original principals of CodeIgniter: Light footprint, low barrier to entry.</p>
<p>If I had to underscore my own objectives in implementing new features, they are <em>speed, efficiency, and power</em>. That is:</p>
<ul>
<li>Does it belong in the framework?</li>
<li>Can this feature be built efficiently?</li>
<li>At the highest level of efficiency, will it be fast?</li>
<li>Is it comparably robust, and powerful in the face of similar features in other frameworks?</li>
</ul>
<p><strong> </strong></p>
<p><strong>A word to the skeptics:</strong></p>
<p>A <a href="http://twitter.com/davidjmemmett/status/10462351392251904">tweet I saw immediately following the Reactor Announcement</a> was “Death by bureaucracy is the fate for CodeIgniter shame … Good riddance, it never matured”. This really embodies the sentiment most users have about <em>other</em> frameworks. It’s arguably the fate that Kohana and Cake have seen.</p>
<p>What I’m saying is: stuff away the cynicism until the first quarter of 2011. You’re going to see a ton a positive changes in the framework, and CodeIgniter users will have plenty to brag about without sacrificing usability and documentation.</p>
<p>There are 6 engineers on the dev team — one who I know very well, and a few others who I’ve met just recently. In all honestly, I’ve been very impressed by everyone, and I couldn’t imagine anything but a bright future for the framework. The other devs are:</p>
<ul>
<li><a href="http://johncrepezzi.com">John Crepezzi</a></li>
<li><a href="http://funkatron.com/">Ed Finkler</a></li>
<li><a title="Great, informative site :)" href="http://www.markhuot.com/">Mark Huot</a></li>
<li><a href="http://kennymeyers.com/">Kenny Meyers</a></li>
<li><a href="http://philsturgeon.co.uk/">Phil Sturgeon</a></li>
</ul>
<p>Six developers can approach the “too many cooks” scenario, but I think you’d also have to recognize that CodeIgniter is supported by volunteers, and a project needs 5 or 6 people in order maintain consistently high activity when they’re generally working on it part-time.</p>
<p><strong>Okay, so now what:</strong></p>
<p>Over the next few weeks, the Reactor team will be getting organized and planning out the future of CodeIgniter. Check back here or at my <a href="http://twitter.com/_kennyk_">Twitter feed</a>, because I’ll definitely post a podcast outlining exactly what the Reactor team plans to do. Also, I tend to lurk around the IRC #codeigniter channel on freenode as _kennyk_ .</p>
<p>If you have any questions, comments, or general skepticism, comment below. I’m all-ears.</p>
]]></content:encoded>
			<wfw:commentRss>http://codefury.net/2010/12/codeigniter-reactor/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>A Better WordPress Search with WPSearch 2.0.2.0</title>
		<link>http://codefury.net/2010/11/wpsearch-released-lives-change/</link>
		<comments>http://codefury.net/2010/11/wpsearch-released-lives-change/#comments</comments>
		<pubDate>Fri, 12 Nov 2010 02:57:58 +0000</pubDate>
		<dc:creator>Kenny Katzgrau</dc:creator>
				<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Search Engine Development]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Wordpress Development]]></category>

		<guid isPermaLink="false">http://codefury.net/?p=272</guid>
		<description><![CDATA[I&#8217;m definitely not the type to evangelize something I don&#8217;t think is useful. Ask friends of mine, and they&#8217;ll likely tell you how I went through phases where I endlessly promoted things like Notepad++ for Windows, Netbeans IDE (PHP), Sequel Pro, Gnome-Do, Thinkpads, Macbooks, Toy Story 3, iPod Touches, and Visual Studio &#8217;08. I just [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcodefury.net%2F2010%2F11%2Fwpsearch-released-lives-change%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcodefury.net%2F2010%2F11%2Fwpsearch-released-lives-change%2F&amp;source=_kennyk_&amp;style=normal&amp;space=12&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;m definitely not the type to evangelize something I don&#8217;t think is useful. Ask friends of mine, and they&#8217;ll likely tell you how I went through phases where I endlessly promoted things like Notepad++ for Windows, Netbeans IDE (PHP), Sequel Pro, Gnome-Do, Thinkpads, Macbooks, Toy Story 3, iPod Touches, and Visual Studio &#8217;08. I just can&#8217;t help it. When I get excited about something, I have a hard time stfu-ing.</p>
<p>But <strong>holy crap</strong>. Let me tell you — if you think the WordPress default search sucks — as I did 2 years ago, <a href="http://wordpress.org/extend/plugins/wpsearch/">try WPSearch</a>. It&#8217;s (IMO) the second-most-useful plug-in that has ever existed for WordPress. It also has the slickest admin UI I&#8217;ve ever used in WordPress (a big thanks to JQuery and it&#8217;s plug-ins, of course).</p>
<p>I wrote WPSearch, and I 100% recommend it to anyone running something that isn&#8217;t a traditional WordPress blog. Run a recipe catalog? <strong>Use It!</strong> Review engine? <strong>Use it! </strong>Shopping engine? <strong>What the hell are you doing without my plug-in on your site? Your customers can&#8217;t find shit!</strong></p>
<p><strong>Fun scenario:</strong> Let&#8217;s imagine you sold laser printers on your site along with other computer peripherals, and every product page on your site had &#8220;[brand] [model] Printers&#8221; in it&#8217;s title, like &#8220;Dell 1100 Laser Printer&#8221;. If someone searched for &#8220;printers&#8221; with default WordPress search, they wouldn&#8217;t get those products back.</p>
<p>Does that scare you? It should.<a href="http://wordpress.org/extend/plugins/wpsearch/"> Get WPSearch now</a>. And if you don&#8217;t like it, tweet <strong>@_kennyk_</strong> and be brutally honest. I can take it.</p>
<p>Side note #1: When I wrote WPSearch, I was also trying to cash-in big time at a programming contest where the grand prize was a trip to RailsConf and the runner-up would get a set of steak knives (presumably to stab whoever won the grand prize).</p>
<p>Side note #2: Toy Story 3 is an intellectually provocative and introspective masterpiece!</p>
<p>Side note #3: Askimet is #1, but is tragically taken for granted</p>
]]></content:encoded>
			<wfw:commentRss>http://codefury.net/2010/11/wpsearch-released-lives-change/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Best WordPress Search Plug-in: WPSearch 2</title>
		<link>http://codefury.net/2010/10/the-best-wordpress-search-plug-in-wpsearch-2/</link>
		<comments>http://codefury.net/2010/10/the-best-wordpress-search-plug-in-wpsearch-2/#comments</comments>
		<pubDate>Tue, 26 Oct 2010 13:05:38 +0000</pubDate>
		<dc:creator>Kenny Katzgrau</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Search Engine Development]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Wordpress Development]]></category>

		<guid isPermaLink="false">http://codefury.net/?p=262</guid>
		<description><![CDATA[If you want to read about the background of the WPSearch Search plug-in for WordPress, read below. But if you just want the gist of this post, here it is: WPSearch is the best search plug-in for your WordPress blog. It is a stemming, stop-word blocking, fast, relevant, fulltext search for WordPress. There isn&#8217;t a [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcodefury.net%2F2010%2F10%2Fthe-best-wordpress-search-plug-in-wpsearch-2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcodefury.net%2F2010%2F10%2Fthe-best-wordpress-search-plug-in-wpsearch-2%2F&amp;source=_kennyk_&amp;style=normal&amp;space=12&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>If you want to read about the background of the WPSearch Search plug-in for WordPress, read below. But if you just want the gist of this post, here it is:</p>
<p><strong>WPSearch is the best search plug-in for your WordPress blog</strong>. It is a stemming, stop-word blocking, fast, relevant, fulltext search for WordPress. <em>There isn&#8217;t a single plug-in in the WordPress repository that can do what it does</em>.</p>
<p>You can get it here: <a href="http://wordpress.org/extend/plugins/wpsearch/">http://wordpress.org/extend/plugins/wpsearch/</a> &#8212; or just install it through the WordPress plugin administration backend. Just search for WPSearch.</p>
<p>If you run any sort of monetized blog, you might be losing sales or readership if users can&#8217;t find what they need on your site. <a href="http://www.adotas.com/2010/09/on-site-search-the-other-white-meat/">According to Adotas, 43% of users hit the search box first</a>.</p>
<p><strong>Background:</strong></p>
<p>I&#8217;ll admit that I&#8217;ve been pretty vocal already about WordPress&#8217; lacking search functionality. I&#8217;ve been vocal about it for 2 years, and it was the original impetus to get this blog up and running. It was also the reason that I wrote wpSearch, the original version of WPSearch &#8212; the lucene-based search plug-in for WordPress. wpSearch was the first true fulltext search for WordPress, in my opinion.</p>
<p>But the problem with wpSearch was that it wasn&#8217;t highly engineered. I had written it for a programming contest, and I was on a tight deadline &#8212; and when projects are rushed, the quality of code goes down. And because of that, bugs made their way out of the woodwork over the next two years.</p>
<p>Consumed by college work and my job, I didn&#8217;t have much time to address those issues. In fact, I had declared wpSearch unsupported a year after it was released in 2009.</p>
<p>A year following that, <a href="http://pixelberry.co.nz/">Daniel Hay at Pixelberry in New Zealand</a> had requested that I add the ability of searching within a category for a client of his. That&#8217;s when WPSearch 2 development began.</p>
<p>I wanted to give wpSearch a full rewrite, and correct several mistakes I made with the first version:</p>
<ul>
<li>Rename it from wpSearch to WPSearch</li>
<li>Change the listing name in the WordPress repository to WP Search, so searches for &#8216;search&#8217; would bring it up</li>
<li>Follow and MVC pattern (it&#8217;s a complex plug-in)</li>
<li>Build a configurable search driver framework, so any driver could be written to search and index</li>
<li>Build better logging</li>
<li>Evangelize it to no end (wpSearch was barely promoted)</li>
<li>Give it a UI independent of the default WordPress stylesheets, and also make it stylish</li>
</ul>
<p>The biggest change is the configurable driver part. The free version of WPSearch contains a driver that uses Zend Lucene in the background. Any driver, however, can be written to work with WPSearch. Drivers for SOLR, sphinx, the Google Search Appliance, or name-your-own-search-product could be written.</p>
<p>I did that because PHP is not the best language to write a search engine in. Since Zend_Search_Lucene is the backend driver of the free version, there is an upper-bound of scalability on the plug-in. After all PHP is a scripting language, and I doubt Zend ever really imagined someone would make the ludicrous decision of indexing tens of thousands of posts in PHP. I found the breaking point to be about 20,000 docs. At that point, I ran into memory issues, slow mid-indexing optimizations, and slow first-hit (non-cached) searches.</p>
<p>So the point is that I poured everything I had into WPSearch 2, and I want to tell everyone about it. I did this project under the umbrella of OConf, my start-up, with business partner John Crepezzi. John&#8217;s an ex-engineer at Sun Microsystems, and he spends his days at Patch.com now. He also wrote the backend driver for WPSearch Pro, an alternate driver for WPSearch 2 which can handle up to 500,000 docs.</p>
<p>John and I gave a talk at Wordcamp NYC, where we officially launched WPSearch 2.The topic was on the default WordPress search, and why avoiding a remedy to it can lose you both readers and money. If you run a shopping engine, people can&#8217;t find your products. If you run a news site, readers can&#8217;t find your content.</p>
<p>If you don&#8217;t think people even use the search box &#8212; heads up, the advertising gurus at Adotas say <a href="http://www.adotas.com/2010/09/on-site-search-the-other-white-meat/">43% of users who find your site do</a>.</p>
<p>You can check it out here: <a href="http://wordpress.org/extend/plugins/wpsearch/">http://wordpress.org/extend/plugins/wpsearch/</a> . In it&#8217;s short time in the repository (about 9 days), it&#8217;s already had around 1,000 downloads, and I&#8217;ve had a lot of positive feedback coming in. I also dropped <a href="http://ma.tt/2009/07/acquia-searc/#comments">a comment about it on WordPress founder Matt Mullenweg&#8217;s site, where he mentioned a search product for Drupal</a>. Hopefully he&#8217;ll check it out and let me know what he thinks.</p>
<p>Check it out!</p>
]]></content:encoded>
			<wfw:commentRss>http://codefury.net/2010/10/the-best-wordpress-search-plug-in-wpsearch-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<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[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcodefury.net%2F2009%2F12%2Fflushing-codeigniters-uri-based-cache-part-i%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcodefury.net%2F2009%2F12%2Fflushing-codeigniters-uri-based-cache-part-i%2F&amp;source=_kennyk_&amp;style=normal&amp;space=12&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<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>4</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[Update: You can find KLogger on github. 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 [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcodefury.net%2F2008%2F07%2Fklogger-a-simple-logging-class-for-php%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcodefury.net%2F2008%2F07%2Fklogger-a-simple-logging-class-for-php%2F&amp;source=_kennyk_&amp;style=normal&amp;space=12&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><b>Update:</b> You can find <a href="https://github.com/katzgrau/KLogger">KLogger on github</a>.</p>
<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>7</slash:comments>
		</item>
	</channel>
</rss>

