<?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>Casey A. McLaughlin &#187; admin</title>
	<atom:link href="http://www.caseymclaughlin.com/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.caseymclaughlin.com</link>
	<description>Online Portfolio</description>
	<lastBuildDate>Fri, 30 Sep 2011 13:10:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>CodeIgniter on the Command-Line</title>
		<link>http://www.caseymclaughlin.com/2010/10/codeigniter-on-the-command-line/</link>
		<comments>http://www.caseymclaughlin.com/2010/10/codeigniter-on-the-command-line/#comments</comments>
		<pubDate>Fri, 22 Oct 2010 14:44:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[maintenance script]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.caseymclaughlin.com/?p=239</guid>
		<description><![CDATA[This post describes my adventures in writing a CLI-interface for CodeIgniter and links to my source, so you can do the same!]]></description>
			<content:encoded><![CDATA[<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.type=&amp;rft.format=text&amp;rft.title=CodeIgniter on the Command-Line&amp;rft.source=Casey A. McLaughlin&amp;rft.date=2010-10-22&amp;rft.identifier=http://www.caseymclaughlin.com/2010/10/codeigniter-on-the-command-line/&amp;rft.language=English&amp;rft.aulast=Administrator&amp;rft.aufirst=Mister&amp;rft.subject=Web Development"></span>
<p><a href="http://www.caseymclaughlin.com/wp-content/uploads/2010/10/syntax_error.jpg"><img class="alignright size-thumbnail wp-image-242" title="Syntax Error" src="http://www.caseymclaughlin.com/wp-content/uploads/2010/10/syntax_error-150x150.jpg" alt="Credit: http://www.flickr.com/photos/ripton/" width="150" height="150" /></a>So, yesterday, I spent a few hours trying to create a robust command-line interface for one of my CodeIgniter applications.  I learned a lot about PHP-CLI.  I also came to remember why it&#8217;s a bad idea to <a title="Yeah, it works, but not how you'd like it to." href="http://punditkitchen.files.wordpress.com/2009/07/128926408767331749.jpg">try and fit a round peg in a square hole</a>.</p>
<p>The thing is, CodeIgniter is a great little <strong><em><span style="text-decoration: underline;">web</span></em></strong> framework.  See the key word in that sentence?  Yes, you can hack some CLI functionality in, but if you want to start doing fancy stuff like adding multiple levels of interactive menus and such, then its time to rethink what you&#8217;re doing.</p>
<p>On the other hand, there are many reasons to create a <strong><em>simple</em></strong> CLI-interface to your web application.  The main use would be for running of maintenance tasks and automated CRON scripts.  For this kind of task, it&#8217;s very easy to create a CLI entry-point for your app.</p>
<a name="How+to+Do+It."></a><h3><span id="more-239"></span>How to Do It.</h3>
<p>I started off by grabbing some <a title="Scroll down in the article to Rule number 4" href="http://net.tutsplus.com/tutorials/php/6-codeigniter-hacks-for-the-masters/">advice from NetTuts</a> and downloading <a title="Go Git the Code" href="http://github.com/philsturgeon/codeigniter-cli">Phil Sturgeon&#8217;s excellent CLI library</a>.</p>
<p>In the same folder as the main <em>index.php </em>file, I created another file named <em>entry.php</em> to serve as my CLI entry to the application.  That file looks like:</p>
<p><script src="http://bitbucket.org/caseyamcl/snippets/src/11525f389fb7/ci-cli/entry.php?embed=t"></script> Notice that I am accepting command-line arguments.  The above code will halt execution and exit if any unknown command-line arguments are given.  It assumes the first non-switch command line argument is the action the user wants to run.  It automatically prepends the &#8220;utils&#8221; controller to the route, thereby sandboxing CLI access to a single controller.  The controller can do whatever you want.  Here&#8217;s a small example wherein I present a main menu if no route was specified when the user runs the CLI interface:  <script src="http://bitbucket.org/caseyamcl/snippets/src/11525f389fb7/ci-cli/controller.php?embed=t"></script></p>
<p>Notice the main menu!  The design goal for the Controller was for the main menu <em>index</em> method to be interactive, but every other method to be able to run unattended if parameters are sent, otherwise to display prompts.</p>
<p>I also made some heavy modifications and additions to the CLI.php library, adding the ability to run any form_validation validation function against command-line inputs (w00t), adding the ability to display view files easily, and adding a few other helper method here and there.</p>
<p>The code is too long to display in this post, but here&#8217;s a link to the <a title="The CLI Library source" href="http://bitbucket.org/caseyamcl/snippets/src/tip/ci-cli/CLI.php">file source on Bitbucket</a>.</p>
<a name="Wrap-Up"></a><h3>Wrap-Up</h3>
<p>It&#8217;s definitely not a good idea to attempt a full, robust, multi-level CLI interface for your CodeIgniter application, but this framework will help you setup a simple, even slightly-interactive CLI interface to make running maintenance tasks and providing basic tools easier for your CLI users.</p>
<p>The repository with all of the code is available on my <a title="CodeIgniter CLI on Bitbucket" href="http://bitbucket.org/caseyamcl/snippets/src/tip/ci-cli/">Bitbucket page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.caseymclaughlin.com/2010/10/codeigniter-on-the-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello World!</title>
		<link>http://www.caseymclaughlin.com/2009/06/hello-world/</link>
		<comments>http://www.caseymclaughlin.com/2009/06/hello-world/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 15:54:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[blog tips]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[humor]]></category>
		<category><![CDATA[introduction]]></category>
		<category><![CDATA[welcome]]></category>

		<guid isPermaLink="false">http://www.caseymclaughlin.com/?p=1</guid>
		<description><![CDATA[After a long hiatus, I reacquaint myself with my good old friend, the Blog.  Plus, I share some tips for good blogging that I found from that supreme authority, The Internet.]]></description>
			<content:encoded><![CDATA[<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.type=&amp;rft.format=text&amp;rft.title=Hello World!&amp;rft.source=Casey A. McLaughlin&amp;rft.date=2009-06-19&amp;rft.identifier=http://www.caseymclaughlin.com/2009/06/hello-world/&amp;rft.language=English&amp;rft.aulast=Administrator&amp;rft.aufirst=Mister&amp;rft.subject=General"></span>
<p><img class="alignright size-full wp-image-25" title="horse-in-car" src="http://www.caseymclaughlin.com/wp-content/uploads/2009/06/horse-in-car.png" alt="horse-in-car" width="190" height="141" />Well, I&#8217;m back.</p>
<p>It&#8217;s been exactly two years, six months, 1 day, and 12 minutes since I last published a post on my website.  You could say that I <span style="text-decoration: line-through;">took a vacation from blogging</span> got a real job, so coming back to the activity of blogging feels like running into an old friend that I&#8217;ve hardly talked to in years.  Do you feel the tension?!  Recently, my sister asked me to dig up some old blog posts, and you know what?  Reading my old posts, I remembered just how much fun it is to write.</p>
<p><span id="more-1"></span></p>
<p>The problem is that my writing skills have grown rusty, since I have spent the past eight years in a &#8220;business&#8221; environment writing:</p>
<ul>
<li>mostly bullet</li>
<li>statements directed</li>
<li>at managers and deans</li>
<li>who &#8220;don&#8217;t have time&#8221; to</li>
<li>appreciate literary wit&#8230;</li>
</ul>
<p>&#8230;so I&#8217;ve been trolling the Internet looking for good tips for blogging.  Here&#8217;s a smattering of what I&#8217;ve found:</p>
<a name="1.+Offer+the+Reader+Something"></a><h3>1. Offer the Reader Something</h3>
<p>So, I can tell you right now that this post will offer you <strong>absolutely no rewarding value</strong>.  There it is.  In fact, I wrote it just in order to have something besides the WordPress default post to start off with.  So, now that we have gotten that out of the way, the next tip I found was:</p>
<a name="2.+Include+Bulleted+Point+Lists"></a><h3>2. Include Bulleted Point Lists</h3>
<p>Done!  See my bulleted list above.  Actually, I&#8217;m a pro at this.  One thing I&#8217;ve learned over the past few years is that nobody in my department has an inclination for reading.  Especially not emails.  Especially not from me.  So, I&#8217;ve learned to avoid complete thoughts, because writing bullets is just way more effective.  But anyhow, I also read that you should&#8230;</p>
<a name="3.+Make+Headlines+Snappy"></a><h3>3. Make Headlines Snappy</h3>
<p>What could be better than &#8220;Hello World!&#8221;  And, I&#8217;ve included a nice &#8220;hello&#8221;-themed picture to go along with it.</p>
<a name="4.+Write+with+Passion"></a><h3>4. Write with Passion</h3>
<p>You can&#8217;t see me right now, but believe me, I am writing with much passion and vigor.  The reason for this is that I have had at least eight cups of coffee in the past three hours.  My right eye is pulsating like crazy and my hands are like paint shakers.  But, as <a title="I'm referring to paragraph 5 of the Wikipedia article, if you are curious" href="http://en.wikipedia.org/wiki/Paul_Erd%C5%91s">Paul Erdős</a> has taught us, without amphetamines, there can be no creativity.</p>
<a name="5.+Publish+Often"></a><h3>5. Publish Often</h3>
<p>Well, if you consider every two years to be &#8220;often&#8221;, strictly speaking, then I am good.</p>
<p>Seriously, I do plan to put a lot of useful stuff here.  The problem most people have with blogging is thinking up good content to share.  Some people spend weeks tinkering with their blog&#8217;s design and playing with plugins but then forget to, y&#8217;know, write something.  I, on the other hand, have a laundry-list of topics queued up to be posted here.  So, now that we&#8217;ve cut the tension and gotten introductions out of the way, I look forward to reacquainting myself with my blog.</p>
<p>It&#8217;s been a long time, old friend.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.caseymclaughlin.com/2009/06/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

