<?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"
	>

<channel>
	<title>@TheKeyboard</title>
	<atom:link href="http://www.littlehart.net/atthekeyboard/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.littlehart.net/atthekeyboard</link>
	<description>Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.</description>
	<pubDate>Thu, 09 Oct 2008 21:07:10 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>A New Way Of Judging Frameworks:  Where are the tests?</title>
		<link>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F10%2F09%2Fa-new-way-of-judging-frameworks-where-are-the-tests%2F&amp;seed_title=A+New+Way+Of+Judging+Frameworks%3A++Where+are+the+tests%3F</link>
		<comments>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F10%2F09%2Fa-new-way-of-judging-frameworks-where-are-the-tests%2F&amp;seed_title=A+New+Way+Of+Judging+Frameworks%3A++Where+are+the+tests%3F#comments</comments>
		<pubDate>Thu, 09 Oct 2008 21:07:10 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
		
		<category><![CDATA[Chris' Brain]]></category>

		<category><![CDATA[frameworks]]></category>

		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=324</guid>
		<description><![CDATA[
As a project for work gets ready for an alpha release, I&#8217;ve managed to eliminate all the serious bugs and now have some time for what should&#8217;ve been part of the project from the beginning:  writing tests. As a lapsed tester, I always feel guilty about not writing tests when things start to get [...]]]></description>
			<content:encoded><![CDATA[<p>
As a <a href="http://sportso.com">project for work</a> gets ready for an alpha release, I&#8217;ve managed to eliminate all the serious bugs and now have some time for what should&#8217;ve been part of the project from the beginning:  writing tests. As a lapsed tester, I always feel guilty about not writing tests when things start to get complicated with an application.  Whenever you make a change, you have to point-and-click your way through the application to make sure that nothing has broken.  I got tired of pointing-and-clicking, so I decided it was time to shut up and write some tests.  Since I&#8217;m using Code Igniter instead of CakePHP for this project (did I mention that I inherited the project and couldn&#8217;t switch?) I started looking into the culture of testing surrounding Code Igniter.  It&#8217;s weaker than a newborn baby.
</p>
<p>
The built-in testing system is some weird mishmash of unit testing and &#8220;you have to create your own test results template&#8221;.  WTF?  You can&#8217;t be serious.  So I quickly ignored that.  Besides, the first set of tests were going to be using <a href="http://phpunit.de">PHPUnit</a> combined with <a href="http://selenium.openqa.org/">Selenium</a> so I could make the &#8220;acceptance testing&#8221; automated.  As an aside to this, I remember speaking with Sebastian Bergmann (the driving force behind PHPUnit) at a conference maybe 3 years ago and him telling me that he knew someone was working on getting Selenium and PHPUnit to play nicely together.  Anyway, it&#8217;s working just fine.
</p>
<p>
So, next step was to see if I could use something else than the incredibly lame testing tools that Code Igniter came with.  I found something called <a href="/www.foostack.com/foostack/">fooStack</a>, that contained CIUnit.  It lets you use PHPUnit with Code Igniter.  Now we&#8217;re talking!  Lickety split I had some unit tests for my models written.  Well, after spending quite a lot of time screwing around with the tests and finding out the difference in relative paths between the application running via Apache and trying to test the models via the command line.  Thanks to all those on Twitter who yelled &#8220;use php_sapi_name to figure out what environment you are in, you idiot!&#8221; at me.
</p>
<p>
But all this got me to thinking:  how do some other PHP frameworks stack up in terms of having tests?</p>
<ul>
<li>Code Igniter has ZERO tests for the framework itself.  Perhaps I will mention this to my boss next time I&#8217;m asked to create a project from scracth.  Hrm, guess I&#8217;ll have to trust that their code actually works the way it&#8217;s supposed to.</li>
<li>Zend Framework (full disclosure: I was one of the original authors of the Zend_Service_Audioscrobbler component) has huge amounts of tests for the framework itself.  In fact, any new contributions MUST have working tests submitted with it.</li>
<li>CakePHP has lots of tests for the core, and I believe that I saw something in the changelog for CakePHP 1.2RC3 that indicated they were at 80% code coverage in terms of testing for the CakePHP core.  Bug submissions for CakePHP are supposed to come with tests to prove that there is a repeatable problem.</li>
<li>Symfony recently rewrote it&#8217;s core tests and created their own testing framework for it.</li>
</ul>
<p>So now when you start comparing frameworks to each other, I think it&#8217;s important you also consider how much effort has gone into creating tests for the core functionality of that framework.  A well tested framework should mean far less surprises when using it.  Given how many tools are out there to assist you in testing, I don&#8217;t think there are any excuses other than being totally lazy to not create tests for the core functionality of any application.  Pay now, or pay later, but you will PAY to fix bugs in your application.  Paying now is simply cheaper.
</p>
<p>
Would you stake your project on complex code written by someone else that is simply not testable by you?  Perhaps I am not looking at from the proper distance because I am inside the framework-creator culture, but I can&#8217;t see why you wouldn&#8217;t want to provide tests to prove your stuff actually works the way you claim it does.  Tests prove that the code is *behaving* the way you expect, and code that is testable is also usually easier to modify as time goes on.  There is some sort of sick joy in making a change to code, running the unit tests, and seeing that you didn&#8217;t break anything.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F10%2F09%2Fa-new-way-of-judging-frameworks-where-are-the-tests%2F&amp;seed_title=A+New+Way+Of+Judging+Frameworks%3A++Where+are+the+tests%3F/feed/</wfw:commentRss>
		</item>
		<item>
		<title>CakePHP 1.2RC3 Released</title>
		<link>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F10%2F02%2Fcakephp-12rc3-released%2F&amp;seed_title=CakePHP+1.2RC3+Released</link>
		<comments>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F10%2F02%2Fcakephp-12rc3-released%2F&amp;seed_title=CakePHP+1.2RC3+Released#comments</comments>
		<pubDate>Thu, 02 Oct 2008 18:26:55 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
		
		<category><![CDATA[Chris' Brain]]></category>

		<category><![CDATA[CakePHP]]></category>

		<category><![CDATA[Rallyhat]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=321</guid>
		<description><![CDATA[Thanks to the power of Twitter I found out that The Show for CakePHP was resuscitated and brought back to life last night.  I listened to the (surprisingly short) show, the main thrust of which was that CakePHP 1.2RC3 was released last night.  Why should you care?

Final RC before a final 1.2 release
Significant [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to the power of Twitter I found out that <a href="http://live.cakephp.org">The Show for CakePHP</a> was resuscitated and brought back to life last night.  I listened to the (surprisingly short) show, the main thrust of which was that CakePHP 1.2RC3 was released last night.  Why should you care?</p>
<ul>
<li>Final RC before a final 1.2 release</li>
<li>Significant speed increases in the wake of <a href="http://talks.php.net/show/froscon08">Rasmus Lerdorf&#8217;s talk about PHP framework performace</a>, and Cake&#8217;s poor showing.</li>
<li>A chance to totally break your application by upgrading!</li>
</ul>
<p>
Well, maybe not so much on the last item but it&#8217;s ALWAYS good to see any project make a significant release.  1.2 has been in the works for more than 18 months, which seems to many to be way too long.  I&#8217;m not so sure I share that sentiment.  If the goal is to try and produce quality releases, then &#8220;it&#8217;s done when it&#8217;s done&#8221; is a reasonable answer.  I&#8217;m sure this is not a new argument, so I won&#8217;t get into it here.
</p>
<p>
My own contributions to RC3 have been, what&#8217;s the word&#8230;non-existent.  Non-computer hobbies + side work = no time to contribute to Cake.  I found out that commit access for people who haven&#8217;t contributed anything in more than 60 days has been revoked, but that&#8217;s really just a minor annoyance.  I&#8217;m sure I could get it back by asking nicely and actually having something to contribute.
</p>
<p>
But I think I&#8217;ve gotten back into Cake developing at the right time as I caved in and decided that my long-rumoured <a href="http://www.rallyhat.com">plan-a-road-trip site</a> shall be built in CakePHP after all.  Yes, I&#8217;ve been playing around with Django but I&#8217;m violating one of my favourite rules:  Just Build It, Damnit!  I&#8217;ve been fooling around with <a href="http://www.balsamiq.com/products/mockups/">Balsamiq Mockups</a> to do the pages and are now digging around for helpers to do the mapping mashup I need.  If you want to mock me over how little progress I&#8217;ve made, feel free to visit the site.  If you&#8217;d like to get involved at all (I could use some help on the &#8220;make a pretty UI for it&#8221; front) let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F10%2F02%2Fcakephp-12rc3-released%2F&amp;seed_title=CakePHP+1.2RC3+Released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Komodo and CakePHP</title>
		<link>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F09%2F19%2Fkomodo-and-cakephp%2F&amp;seed_title=Komodo+and+CakePHP</link>
		<comments>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F09%2F19%2Fkomodo-and-cakephp%2F&amp;seed_title=Komodo+and+CakePHP#comments</comments>
		<pubDate>Fri, 19 Sep 2008 17:47:53 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
		
		<category><![CDATA[Chris' Brain]]></category>

		<category><![CDATA[CakePHP]]></category>

		<category><![CDATA[Komodo]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=318</guid>
		<description><![CDATA[
For those who remember how I was an editor waffler will remember that I play around with Komodo from time to time, and decided to get back into using it again.  There are alpha 5.0 versions available so I downloaded one and tried it out.  Seems to be less resource hungry than previous [...]]]></description>
			<content:encoded><![CDATA[<p>
For those who remember how I was an <a href="http://www.littlehart.net/atthekeyboard/2008/03/18/im-an-editor-waffler/">editor waffler</a> will remember that I play around with <a href="http://community.activestate.com/products/Komodo">Komodo</a> from time to time, and decided to get back into using it again.  There are alpha 5.0 versions available so I downloaded one and tried it out.  Seems to be less resource hungry than previous versions (as in it doesn&#8217;t cause my fan in  my MacBook to start up every time I open Komodo).  Now, since I know a few people at Activestate I emailed Jeff Griffiths to ask him a few questions.  He responded by hacking together something very quickly for <a href="http://community.activestate.com/node/2794">adding code intelligence for CakePHP to your views</a>.  If you&#8217;re a Komodo user (or are interested in trying out Komodo), try it out and let Jeff know how it&#8217;s working out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F09%2F19%2Fkomodo-and-cakephp%2F&amp;seed_title=Komodo+and+CakePHP/feed/</wfw:commentRss>
		</item>
		<item>
		<title>What&#8217;s In Chris&#8217; Brain: September 2008 Edition</title>
		<link>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F09%2F16%2Fwhats-in-chris-brain-september-2008-edition%2F&amp;seed_title=What%26%238217%3Bs+In+Chris%26%238217%3B+Brain%3A+September+2008+Edition</link>
		<comments>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F09%2F16%2Fwhats-in-chris-brain-september-2008-edition%2F&amp;seed_title=What%26%238217%3Bs+In+Chris%26%238217%3B+Brain%3A+September+2008+Edition#comments</comments>
		<pubDate>Tue, 16 Sep 2008 17:58:19 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
		
		<category><![CDATA[Chris' Brain]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=315</guid>
		<description><![CDATA[
It&#8217;s time again for a round-up of the ideas that have been bouncing around in my head this past month, because I don&#8217;t have enough material for a big blog post.  Not yet, any way.


Oh look, another CakePHP book coming out that I can review if the author pulls some strings.  Yes, I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>
It&#8217;s time again for a round-up of the ideas that have been bouncing around in my head this past month, because I don&#8217;t have enough material for a big blog post.  Not yet, any way.
</p>
<ul>
<li>Oh look, <a href="http://manning.com/obrien/">another CakePHP book</a> coming out that I can review if the author pulls some strings.  Yes, I&#8217;m talking to YOU AD7Six</li>
<li>Although the title of the presentation is <a href="http://www.youtube.com/watch?v=i6Fr65PFqfk">&#8220;Why I Hate Django&#8221;</a>, Cal Henderson from Flickr shows why you simply cannot avoid frameworks when building applications.  Deny this fact at your own peril.</li>
<li>If you&#8217;re not already reading their blog, check out Felix and Tim (and sometimes Nate) over at the <a href="http://debuggable.com/">Debuggable Ltd.</a> blog where you can find some of the best CakePHP tips around.  Felix is closing on on 30 straight days of blogging, though not always CakePHP related.</li>
<li>I&#8217;m going to be in Mountain View, CA next Wednesday (the 24th) for a super-secret meeting and have some time to kill before my red-eye flight back home.  Maybe we can hook up so you can hurl abuse at me and so I can get enough alcohol in me to sleep on the red-eye flight back to Toronto?</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F09%2F16%2Fwhats-in-chris-brain-september-2008-edition%2F&amp;seed_title=What%26%238217%3Bs+In+Chris%26%238217%3B+Brain%3A+September+2008+Edition/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Book Review:  CakePHP Application Development</title>
		<link>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F09%2F08%2Fbook-review-cakephp-application-development%2F&amp;seed_title=Book+Review%3A++CakePHP+Application+Development</link>
		<comments>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F09%2F08%2Fbook-review-cakephp-application-development%2F&amp;seed_title=Book+Review%3A++CakePHP+Application+Development#comments</comments>
		<pubDate>Tue, 09 Sep 2008 01:32:58 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
		
		<category><![CDATA[Chris' Brain]]></category>

		<category><![CDATA[book review]]></category>

		<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=312</guid>
		<description><![CDATA[A few weeks ago I was approached by Pakt Publishing and asked if I was interested in reviewing the recent CakePHP book &#8216;CakePHP Application Development&#8217; by Ahsanul Bari and Anupom Syam.  In the interest of full disclosure, I have communicated with Ahsanul a few times via the CakePHP mailing list and on Twitter.  [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I was approached by <a href="http://www.paktpub.com">Pakt Publishing</a> and asked if I was interested in reviewing the recent <a href="http://cakephp.org">CakePHP</a> book <a href="http://www.packtpub.com/cakephp-application-development/book">&#8216;CakePHP Application Development&#8217;</a> by Ahsanul Bari and Anupom Syam.  In the interest of full disclosure, I have communicated with Ahsanul a few times via the CakePHP mailing list and on <a href="http://twitter.com/chartjes">Twitter</a>.  We&#8217;re not total strangers, more like casual acquaintances who know each other through the CakePHP community.</p>
<p>
One of the biggest criticisms in the past of CakePHP was the lack of published documentation on how to use the framework.  As shocking as it was to me, there were people who preferred a paper copy of the Cookbook so they could have access to it when they might not be online (what, working on your computer and not online?!?) or to read offline.  Naturally, several books about the framework have been published in the past few months, and I can&#8217;t think of a better book to recommend to people interested in learning the framework than this one.  And I&#8217;m not just saying that because I got a copy for free.  While the book is good, there are a few places where it could be even better.
</p>
<h2>The Good: Examples, Example, Examples</h2>
<p>
The target audience for this book is the right one that CakePHP is attracting:  intermediate PHP developers who may have not used a framework before and are trying to figure out how to use one to their advantage.  Without clear and relevant examples of how to use it, CakePHP would be just another framework struggling to gain acceptance with the PHP deveoper community.  If you want examples on how to do most basic things with CakePHP, this book has them.  Want to know how to configure CakePHP to work for your web server?  Check!  How do you get results from your database?  Check!  How do you use the &#8216;bake&#8217; utility from the Cake console?  Check!  Validating form fields?  Check!
</p>
<p>
I feel that the examples in this book are it&#8217;s strengths.  The code is well written and every code example is followed by an explanation of what they are doing.  Many times the example is not enough, you have to understand WHY it&#8217;s written that way.</p>
<h2>The Good:  Sample Applications Always Help</h2>
<p>
Almost half the book is devoted to creating an application from scratch, including configuring the often-misunderstood Auth component and showing how the built-in Javascript helper allows you to add Ajax-powered functionality via the Prototype and Scriptaculous Javascript libraries.  Seeing an application being built from start to working prototype is an invaluable lesson for the &#8220;learn from example&#8221; crowd.
</p>
<h2>The Bad:  Less Info On Doing Things The Cake Way</h2>
<p>
I feel that some more time could&#8217;ve been spent explaining CakePHP&#8217;s &#8220;convention over configuration&#8221; preferences and how it changes the way you approach building an application using CakePHP.  Perhaps that wasn&#8217;t a topic for this book&#8217;s intended audience, since it&#8217;s only the deep thinkers and the rant-and-ravers (which I have been accused of belonging to) who like to discuss the philosophy behind CakePHP and the question of just what a framework is good for.
</p>
<p><h2>The Bad: Thin on Server Configuration Information</h2>
</p>
<p>
While there is a chapter devoted to getting CakePHP up-and-running using Apache and MySQL (specifically using <a href="http://www.wampserver.com/en/">WAMP</a>), it would&#8217;ve been very helpful to see an example of the type of configuration recommended for production environments, where the APP directory is web-accessable while the CakePHP core is located somewhere outside the webroot, linked in via an option in the configuration files.
</p>
<h2>The Bad:  No mention of the differences in debug levels</h2>
<p>
When I do my development work on a CakePHP application, I set the debug level to 1 so that I see all errors and the SQL statements being generated by my models.  In production I have the debug level set to 0 as I don&#8217;t want error messages on the screen that reveal any information, and I certainly don&#8217;t want people seeing the SQL statements being executed.  Sure, it&#8217;s security by obscurity but it&#8217;s also debugging information that&#8217;s cluttering up the screen.
</p>
<h2>The Bad: No mention of using the built-in testing</h2>
<p>
While I&#8217;m a lapsed tester, the fact that CakePHP will create the shells for writing unit tests for the models and controllers you create should not be overlooked.  Although testing gets a bad rap (&#8221;It&#8217;s too hard, and it wastes my time!&#8221;) it&#8217;s a programming practice that should be encouraged.
</p>
<h2>The Ugly: CakePHP is still a moving target</h2>
<p>
While this in no way diminishes the efforts put in by the authors to create this excellent introduction to CakePHP, at the time it went to press CakePHP 1.2 was still not feature-final.  Some tihngs have changed, and I expect some more things will change before CakePHP 1.2 is finalized and work on CakePHP 2.0 starts.  This is the danger in writing about any programming language:  the information could become obsolete at any time.  But don&#8217;t get all upset about it, as it is likely only very minor details that have changed.  The CakePHP core team does try to not break things *that* much.
</p>
<p>
So, don&#8217;t let the number of &#8220;bad&#8221; issues above dissuade you from checking out this book.  The items I highlighted are probably bettered suited for a &#8220;Advanced CakePHP Application Development for Grumpy Developers&#8221; book.  I would not hesitate to recommend this book to any semi-experienced PHP developer who is looking for a resource guide to get themselves started.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F09%2F08%2Fbook-review-cakephp-application-development%2F&amp;seed_title=Book+Review%3A++CakePHP+Application+Development/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Don&#8217;t Fear The Command Line: Using CakePHP Shells</title>
		<link>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F09%2F04%2Fdont-fear-the-command-line-using-cakephp-shells%2F&amp;seed_title=Don%26%238217%3Bt+Fear+The+Command+Line%3A+Using+CakePHP+Shells</link>
		<comments>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F09%2F04%2Fdont-fear-the-command-line-using-cakephp-shells%2F&amp;seed_title=Don%26%238217%3Bt+Fear+The+Command+Line%3A+Using+CakePHP+Shells#comments</comments>
		<pubDate>Thu, 04 Sep 2008 20:58:46 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
		
		<category><![CDATA[Chris' Brain]]></category>

		<category><![CDATA[CakePHP]]></category>

		<category><![CDATA[shells]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=310</guid>
		<description><![CDATA[
(Note: this is a reposting of an entry I made when trying out Habari as my blog software.  If you missed it, I hope you enjoy it now.

For a consulting job I'm working on where I'm porting a spaghetti-PHP application over to using CakePHP I am moving their existing authorization system over to using [...]]]></description>
			<content:encoded><![CDATA[<p>
(Note: this is a reposting of an entry I made when trying out <a href='http://habariproject.org'>Habari</a> as my blog software.  If you missed it, I hope you enjoy it now.</p>
<p>
For a consulting job I'm working on where I'm porting a spaghetti-PHP application over to using CakePHP I am moving their existing authorization system over to using Cake's Auth component.  Of course, they are storing all their passwords in plaintext in the user account table, so I needed an easy way to convert all the existing passwords over to be encrypted using the same hash that Auth would use.  Doing this was surprisingly easy thanks to the power of <a href="http://book.cakephp.org/view/110/Creating-Shells-Tasks">shells and tasks in CakePHP.</a>.
</p>
<p><div class="igBar"><span id="lphp-2"><a href="#" onclick="javascript:showPlainTxt('php-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-2">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * Shell for encrypted naked passwords with the correct hash for use</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * with the Auth component</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> *</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * @auth Chris Hartjes</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> EncryptPasswordsShell extends Shell <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$uses</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'UserClient'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> main<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; App::<span style="color:#006600;">import</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Core'</span>, <span style="color:#FF0000;">'Security'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">out</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Starting to encrypt passwords<span style="color:#000099; font-weight:bold;">\n</span><span style="color:#000099; font-weight:bold;">\n</span>"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">UserClient</span>-&gt;<span style="color:#006600;">recursive</span>= -<span style="color:#CC66CC;color:#800000;">1</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$users</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">UserClient</span>-&gt;<span style="color:#006600;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'all'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">foreach</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$users</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$user</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$userName</span> = <span style="color:#0000FF;">$user</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'UserClient'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'username'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$password</span> = <span style="color:#0000FF;">$user</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'UserClient'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'password'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$password</span> != <span style="color:#FF0000;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$data</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'UserClient'</span> =&gt; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'id'</span> =&gt; <span style="color:#0000FF;">$user</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'UserClient'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'id'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'password'</span> =&gt; Security::<span style="color:#006600;">hash</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$password</span>, <span style="color:#000000; font-weight:bold;">null</span>, <span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">UserClient</span>-&gt;<span style="color:#006600;">save</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$data</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">out</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Updated password for {$userName}"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">out</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Bad password for {$userName}"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
</p>
<p>
I think the code in there is pretty self-explanatory.  The only "gotcha" I ran into (fixed by a look at the Auth component itself) was that I needed to tell Security::hash() that I wanted to use the salt I defined in my config file.  By default that parameter is set to false, hence the need to explicitly set it to true.
</p>
<p>
Thank to <a href="http://mark-story.com/">Mark Story</a> for pointing me in the right direction for this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F09%2F04%2Fdont-fear-the-command-line-using-cakephp-shells%2F&amp;seed_title=Don%26%238217%3Bt+Fear+The+Command+Line%3A+Using+CakePHP+Shells/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reader Feedback: Web Application Performance</title>
		<link>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F08%2F28%2Freader-feedback-web-application-performance%2F&amp;seed_title=Reader+Feedback%3A+Web+Application+Performance</link>
		<comments>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F08%2F28%2Freader-feedback-web-application-performance%2F&amp;seed_title=Reader+Feedback%3A+Web+Application+Performance#comments</comments>
		<pubDate>Thu, 28 Aug 2008 18:32:27 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
		
		<category><![CDATA[Chris' Brain]]></category>

		<category><![CDATA[application performance]]></category>

		<category><![CDATA[frameworks]]></category>

		<category><![CDATA[reader feedback]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=307</guid>
		<description><![CDATA[



Welcome to the 4th and final day of reader feedback week here.  Today's topic is one that comes up over and over and over and over again:  web application performance.  In particular, I wanted to discuss web application performance and frameworks.

After seeing a slide from a presentation at FrOSCON about CakePHP's performance [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://www.littlehart.net/images/web-app-development.png"/>
</p>
<p>
Welcome to the 4th and final day of reader feedback week here.  Today's topic is one that comes up over and over and over and over again:  web application performance.  In particular, I wanted to discuss web application performance and frameworks.
</p>
<p>After seeing a slide from a presentation at FrOSCON about CakePHP's performance in the incredibly-unrealistic-and-irrelevant "Hello World" competition against vanilla PHP and other PHP frameworks I came up with that very aggressive statement you see above.  That prompted a flurry of tweets by other people about their thoughts on that matter, and so on and so forth.  I believe my earlier statements were misunderstood, so I shall clarify them here.
</p>
<p>
I stand by the statement "frameworks are about increasing development speed, not application speed".  I've talked about frameworks plenty in the past, and they all promise you this:  if you build things according to their rules (and this is the really important thing to remember) then you will gain a significant increase in application development speed.  If you fight against those rules, why are you even bothering to use the framework?  The goal is to speed up development time by following a set of conventions on how the application is put together.
</p>
<p>
So, if you've had enough courage to build you application with your framework of choice, you should have a working application.  That doesn't mean it is as fast as it could be, but remember the mantra I shared earlier:  "make it work, then make it work better".  Where frameworks typically fall down is in the "make it work better" part of that statement.  <a href="http://www.travisswicegood.com/">Travis Swicegood</a> pointed out to me when it comes to frameworks "...actually, a really good one should have mechanics in place to do both" (referring to increased development speed and application speed).
</p>
<p>
So, if you have a framework that actually cares about application performance (perhaps unfairly some frameworks have decided that performance is sole responsibility of the developer, not the framework itself) then it should come with things to make your application a little more responses.  Things like built-in output caching, or features in their ORM/ADM that cache your schema, things like that.  But in the end, there is only so much you can to make a framework-built application run really fast.  Sometimes you can do it with just the additional features I mentioned above.  Sometimes you can't do it because the architecture you've chosen for your application won't let you.  And sometimes, you can't do anything about it because it's too hard to modify the framework itself.  These things happen.  Look at Twitter and all the contortions they have gone through trying to take what was initially a Rails application and push it's performance up to it's current level.
</p>
<p>
There are also lots of 3rd-party solutions to help you make your application perform better.  <a href="http://www.danga.com/memcached/">Memcached</a> for caching data (ask me some time about my Memached story at an old job). <a href="http://pecl.php.net/package/APC">Alternative PHP Cache</a> if you're running PHP.  <a href="http://www.squid-cache.org/">Squid</a>.  <a href="http://nginx.net/">nginx</a>.  <a href="http://mongrel.rubyforge.org/">Mongrel</a>.  Those are just the ones I can think of off the top of my head.  Some of them are even framework agnostic.</p>
<p>
Having a framework that lets you BUILD things fast and RUN things fast is the perfect situation, but not too common.  I used to get mad when I'd see people asking if <insert framework here> can scale, because I felt it revealed a certain level of ignorance in the person asking the question.  I've now come to the conclusion that what they are really asking is if </insert><insert framework here> can scale without them doing any extra work.  Usually, the answer to that question is FUCK NO (emphasis mine) because scaling is an issue that goes far beyond just a simple framework.<br />
</insert></p>
<p>
See, not every framework is slow.  Some frameworks, due to their internal structure, are faster than others.  I'm okay with that now, not so okay in the past.  In a lot of cases, the bottlenecks in your application aren't code-related.  I've come to understand that too, especially in the new Javascript-driven world web applications have started to run in.  If you think Twitter is slow because they chose Rails, I think that you do not have a firm understanding of how Twitter actually works.  Or maybe you don't care because it's easy to make fun of Rails and Twitter.
</p>
<p>
Luckily, we have lots of free and easy-to-use tools at our disposal that let us look at our up-and-running web application (remember, Just Build It, Damnit!) and see how it's performing.  Things like <a href="http://www.joedog.org/JoeDog/Siege">Siege</a> and <a href="http://developer.yahoo.com/yslow/">YSlow</a> are just two tools that their use will give you huge insights into the actual performance of your web application.
</p>
<p>
You shouldn't be GUESSING how your application performs, you should KNOW what is going on.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F08%2F28%2Freader-feedback-web-application-performance%2F&amp;seed_title=Reader+Feedback%3A+Web+Application+Performance/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reader Feedback: Working with XML In PHP</title>
		<link>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F08%2F27%2Freader-feedback-working-with-xml-in-php%2F&amp;seed_title=Reader+Feedback%3A+Working+with+XML+In+PHP</link>
		<comments>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F08%2F27%2Freader-feedback-working-with-xml-in-php%2F&amp;seed_title=Reader+Feedback%3A+Working+with+XML+In+PHP#comments</comments>
		<pubDate>Wed, 27 Aug 2008 19:53:55 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
		
		<category><![CDATA[Chris' Brain]]></category>

		<category><![CDATA[reader feedback]]></category>

		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=304</guid>
		<description><![CDATA[
Welcome to the 3rd installment of me answering reader feedback questions.  Today we deal with a topic that I deal with every day at my day job -- working with XML in PHP.

First of all, I do all this in PHP 5.  SimpleXML makes it so easy to manipulate XML.  For my [...]]]></description>
			<content:encoded><![CDATA[<p>
Welcome to the 3rd installment of me answering reader feedback questions.  Today we deal with a topic that I deal with every day at my <a href="http://www.xmlteam.com">day job</a> -- working with XML in PHP.</p>
<p>
First of all, I do all this in PHP 5.  SimpleXML makes it so easy to manipulate XML.  For my main work project, I've written a PHP application front end that talks to <a href="http://exist.sourceforge.net">eXist</a>, an open source XML database.  Since we deal with XML all day long it was decided that we needed to <a href="http://en.wikipedia.org/wiki/Eat_one's_own_dog_food">eat our own dog food</a> and go with an XML database to store the information that the <a href="http://sportso.com">application</a> generates.  So a lot of my code does some of the following things:</p>
<ul>
<li>Do a call to a xQuery script running on the database that returns info that I'm looking for, usually both comma and pipe-separated data</li>
<li>Load a specific document into a SimpleXML object and pull out some specific info</li>
<li>Load a specific document into a SimpleXML object and then use it's XPath functions to pull some information out.</li>
</ul>
<p>
Those 3 techniques seem to work well for me when dealing with XML data in PHP.  If I had to go back and redo some of the earlier code, I'd probably change things a little differently in how I'm using eXist to simulate how some of our other products work:</p>
<ol>
<li>Use eXist to give me a list of documents that contain the info I am looking for</li>
<li>Load those documents into SimpleXML</li>
<li>Use Xpath to grab the data I needed</li>
</ol>
<p>But in the interest of Getting Things Done, what I've done works pretty good and the code is really not horrible.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F08%2F27%2Freader-feedback-working-with-xml-in-php%2F&amp;seed_title=Reader+Feedback%3A+Working+with+XML+In+PHP/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reader Feedback: Experiences With Django</title>
		<link>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F08%2F26%2Freader-feedback-experiences-with-django%2F&amp;seed_title=Reader+Feedback%3A+Experiences+With+Django</link>
		<comments>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F08%2F26%2Freader-feedback-experiences-with-django%2F&amp;seed_title=Reader+Feedback%3A+Experiences+With+Django#comments</comments>
		<pubDate>Tue, 26 Aug 2008 21:18:41 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
		
		<category><![CDATA[Chris' Brain]]></category>

		<category><![CDATA[Django]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[reader feedback]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=302</guid>
		<description><![CDATA[Welcome to Day 2 of my answering reader feedback questions here in the month of August.  I was asked to share my experiences with Django.  I will confess that I am a complete n00b when it comes to Python (wrote a few scripts for work-related stuff) and got an early alpha of my [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to Day 2 of my answering reader feedback questions here in the month of August.  I was asked to share my experiences with Django.  I will confess that I am a complete n00b when it comes to Python (wrote a few scripts for work-related stuff) and got an early alpha of my baseball road-trip planning site actually working using Django.  Sure, it was ugly and very rough around the edges but I got it to work.  But I will say this:  if I had the opportunity to start working with Python and Django every day (and for the same pay I'm getting now) I would take it in a heartbeat.  Seriously.
</p>
<p>
So why all the love for Django and Python?  As a guy who's used PHP for a very long time, I'm really blind to the syntax of it.  All the griping about needle vs. haystack and "PHP is ugly" is just wasted on me.  Just so much pissing and moaning by people who should know better and lack the courage to learn the language they way they should.  I heard it described by Evan from Identi.ca as being "the working man's language".  Nothing wrong with that, as PHP is great at Getting Things Done.  But Python...Python is vastly different from PHP.  It's about objects.  It's about consistency.  It's about the most amazing interactive interpreter I've seen since I was a kid fooling around on my VIC-20 typing in programs from Compute! magazine.  Bet you didn't think I'd been using computers for that long.  To shift into bragging mode, I first got paid for programming when I wrote a program for my mother's school (she's a teacher) to create the salary grid for the teachers.  I was 12. I think.
</p>
<p>
Also, there's a dirty little secret about using frameworks that nobody really tells you.  After a while, it makes you lazy.  You forget how to do certain things because, well, the framework does it for you.  The other day there was a tweet from someone asking about the best way to sanitize data before you put it into the database.  My first thought was "sheesh, that's built into the framework" and then I stopped myself and said "you are getting goddamn lazy!".  My response was "try using mysql_real_escape_string(...)" but was also told about using PDO's binding of parameters as another way to do it.  See, those things are all done by the framework meaning lazy old Chris doesn't have to remember how to do it.  Until the time he's confronted with non-framework code that he cannot simply rewrite as part of a framework.  *gulp*.  So, since Python and Django are so different from the other frameworks I've used it forces me to STOP being lazy and actually learn how not only Django itself works but how the insides of it work as well.
</p>
<p>
Now, being an old hand at frameworks means using Django is not that big a stretch.  I spent a lot time googling around for the "Python (or Django) Way" to do things.  Except for a few concepts that are not familiar to a long time PHP guy (generators?) it wasn't that hard to get up and running with Django.  The documentation is awesome, and once you learn to stop writing PHP code in Python and instead embrace doing things the Python way, it becomes a lot easier.
</p>
<p>
In the end it's still datasource-backed models talking to some controller code and passing it onto some template.  I find the Django templates to be very limiting after my initial experiences and my "PHP is the template" background, and I think that as I get deeper into it I really have to find out how to do things the Django way.  What CakePHP calls Model-View-Controller, Django calls Model-View-Template, but it's really the same thing.
</p>
<p>
When I compare Ruby to Python, I don't get the feeling that I will have to resort to dynamic functions and closures to Get Things Done in Django like I see happening in Rails.  Besides, they seem to be two very different communities.  That's probably because the leaders of the Django community are so different in temperament and I don't see the same type of "Django rules, everything else sucks!" mind sets that I saw in the Rails community.  Maybe I'm just looking in the wrong places, but I feel more at ease in the Django community than the Rails community, albeit from the outer fringes of it.
</p>
<p>
So don't be lazy and complacent about the tools that you use.  Go and checkout Django and you might feel the same way about it as I do.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F08%2F26%2Freader-feedback-experiences-with-django%2F&amp;seed_title=Reader+Feedback%3A+Experiences+With+Django/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reader Feedback: Personal Project Management</title>
		<link>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F08%2F25%2Freader-feedback-personal-project-management%2F&amp;seed_title=Reader+Feedback%3A+Personal+Project+Management</link>
		<comments>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F08%2F25%2Freader-feedback-personal-project-management%2F&amp;seed_title=Reader+Feedback%3A+Personal+Project+Management#comments</comments>
		<pubDate>Mon, 25 Aug 2008 18:45:23 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
		
		<category><![CDATA[Chris' Brain]]></category>

		<category><![CDATA[reader feedback]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=300</guid>
		<description><![CDATA[
With August winding down to a close and the insane August family event schedule over with (5 birthdays and my wedding anniversary) I now have the time to answer some of the reader feedback questions I had solicited at the beginning of the month.  So, to give something back I will be answering one [...]]]></description>
			<content:encoded><![CDATA[<p>
With August winding down to a close and the insane August family event schedule over with (5 birthdays and my wedding anniversary) I now have the time to answer some of the reader feedback questions I had solicited at the beginning of the month.  So, to give something back I will be answering one question each day this week.  Today's first topic is Personal Project Management.
</p>
<p>
As I never get tired of telling people, my <a href="http://www.xmlteam.com">employer</a> is one of the enlightened few who lets their employees telecommute 100% of the time, so there are some different challenges in play.  I understand that some people could not "handle the pressure" (their words, not mine, although I am paraphrasing) of working from home.  At this point I could not imagine going BACK to working in an office.
</p>
<p>
So, with your boss always around on IRC and just a phone call away, how does your grumpy correspondent stay on top of his tasks since he knows the boss will never show up at my desk asking me a question?  You may be surprised at the answer if you know me in real life:  through self-discipline.
</p>
<p>Yes, I can already feel the immense amount of eye-rolling (including my <a href="http://www.teachersatrick.com">mother</a>) but it really is true.  If you are the type of person who needs to be constantly told what to do, you are not going to cut it in a telecommute environment because you WILL be left alone for long periods of time to Get Things Done Without Constant Supervision.  The only way to make sure you are able to function without simply going upstairs and watching TV when you are supposed to be working is to, well, act like the professional coder you are supposed to be.  So, how do I handle this?  Please be aware that this is a method that works for me and probably only for me.  Copy it at your own peril.
</p>
<p>
I tend to approach programming assignments as if it was Big Problem that can be solved by breaking it down into Little Problems.  This is why when confronted with the question "is there any programming challenge you solved that you are really proud of?" I tend to draw a blank because, well, despite all my bluster and accusations of being an asshole, I don't really look at the stuff I do and say "goddamn, that was amazing work".  To me, it's really just solving a bunch of smaller problems that make up a bigger problem.  I guess you thought I'm a shameless self-promoter of my work.  I try to do go
</p>
<p>I mean, not every programming task I complete is what I would call exceptional work because sometimes you just can't figure out an exceptional way to do it.  Plus, I can't bring myself to be such an asshole as to expect everything I do to be perfect.  Not everyone is at their best all the time.  Therefore, I try to follow a policy that was explained to me by gwoo from the CakePHP project: "Make it work, then make it work better".  I can't think of a better philosophy for the type of work I do every day.</p>
<p>
Everything beyond how I approach solving problems is really just non-important.  I make lots of notes, but I'm not a compulsive note organizer.  I don't have any system for keeping track of what I'm working on beyond a simple list of items in a spiral notebook that I cross off and scratch away at while I work.  Hate to disappoint people, but I try to keep it very simple.  Whenever I veer off into the land of Complex Task Tracking, I spend more time tracking tasks than doing them.  Keep it simple, keep it something I can use each day and every day.
</p>
<p>
So, that's my approach to personal project management:</p>
<ul>
<li>Be professional since you are, you know, being paid to do it.</li>
<li>Keep your solutions simple</li>
<li>Adopt organizational practices you can follow every day.</li>
<li>Try and do your best work whenever you can, but understand when you are not at your best</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.littlehart.net%2Fatthekeyboard%2F2008%2F08%2F25%2Freader-feedback-personal-project-management%2F&amp;seed_title=Reader+Feedback%3A+Personal+Project+Management/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.843 seconds -->
<!-- Cached page served by WP-Super-Cache -->
<!-- Compression = gzip -->