<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>24yr old developer in Bradenton, FL.  I hold a B.S. in Computer Science and love creating web applications.

I primarily work with Ruby on Rails and PHP 5.3+ with FuelPHP and CodeIgniter frameworks.

I tend to post blurbs I think will be beneficial to others, or bits I just consider awesome in the development world.</description><title>Matthew Machuga</title><generator>Tumblr (3.0; @machuga)</generator><link>http://matthewmachuga.com/</link><item><title>(via tumblr.com)</title><description>&lt;iframe src="http://player.vimeo.com/video/43014286" width="400" height="240" frameborder="0"&gt;&lt;/iframe&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;(via &lt;a href="http://www.tumblr.com/share/video?embed=http%3A%2F%2Fvimeo.com%2Fuser549215%2Flaravel-32-walkthrough" target="_blank"&gt;tumblr.com&lt;/a&gt;)&lt;/p&gt;</description><link>http://matthewmachuga.com/post/24003725533</link><guid>http://matthewmachuga.com/post/24003725533</guid><pubDate>Tue, 29 May 2012 13:17:26 -0400</pubDate></item><item><title>Blackout for SOPA</title><description>&lt;p&gt;My site will be blacked out soon because I strongly oppose SOPA and PIPA.&lt;/p&gt;

&lt;p&gt;See you on the other side :)&lt;/p&gt;</description><link>http://matthewmachuga.com/post/16050058080</link><guid>http://matthewmachuga.com/post/16050058080</guid><pubDate>Wed, 18 Jan 2012 00:16:43 -0500</pubDate></item><item><title>Stuff.all.order(:structured)</title><description>&lt;p&gt;
So it seems my next &amp;#8220;Protect the Environment&amp;#8221; installation may actually be more life involved than my coding environment.  I&amp;#8217;ve been getting busier and busier; more freelance work, more tasks at the office, and more things to manage for myself.  I&amp;#8217;ve been trying to write things down and organize items as they come in, but I&amp;#8217;m currently spread across email, Reminders on iPhone, iCal, Basecamp, notebooks, and whiteboards. &lt;i&gt;I need to centralize&lt;/i&gt;
&lt;/p&gt;

&lt;p&gt;
My mind wanders from task to task too quickly. I&amp;#8217;m very much so a &amp;#8220;shiny object&amp;#8221; kind of guy, so if I don&amp;#8217;t have something written down - it&amp;#8217;s gone.  Might not be for good, but it&amp;#8217;s long enough to disturb my work flow and rob from my productivity.  Simply put - I&amp;#8217;m finally tired of it and going to do something about it.&lt;/p&gt;

&lt;p&gt;
I&amp;#8217;m going to be surveying a few time/task/life management apps over the next week or two to see what fits me best.  Reminders + Siri on my iPhone are still definitely at the forefront of my management tactics - the convenience is amazing when I&amp;#8217;m out and need something jotted down quickly.  However, when I&amp;#8217;m knee deep in code or paperwork, I need something stupid quick that won&amp;#8217;t jar me from my current train of though.  Whether a hotkey, terminal app, or other quick-hit solution, I need to be able to put my idea or reminder, let the thought go, and resume my work flow as quickly as possible.  So far, iCal with some sort of hotkey, task app for the command line, or Evernote have my attention.  Whatever the solution, as long as I can access it from anywhere I&amp;#8217;m happy.
&lt;/p&gt;

&lt;p&gt;That leaves me curious with what others use, and how their thought processes work.&lt;/p&gt;

&lt;p&gt; What tools do you use to stay organized?&lt;/p&gt;</description><link>http://matthewmachuga.com/post/15816662104</link><guid>http://matthewmachuga.com/post/15816662104</guid><pubDate>Sat, 14 Jan 2012 01:32:00 -0500</pubDate></item><item><title>Stop American Internet Censorship</title><description>&lt;p&gt;Read about why my logo is censored out, why the popup shows up today, 11/16/2011, and why you should really help me in supporting the prevention of this bill.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://americancensorship.org/" title="Stop American Internet Censorship" target="_blank"&gt;&lt;a href="http://americancensorship.org/" target="_blank"&gt;http://americancensorship.org/&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;</description><link>http://matthewmachuga.com/post/12880029754</link><guid>http://matthewmachuga.com/post/12880029754</guid><pubDate>Wed, 16 Nov 2011 08:16:05 -0500</pubDate></item><item><title>Community is a Beautiful Thing</title><description>&lt;p&gt;Today I witnessed a beautiful thing emerge from an awful situation.&lt;/p&gt;
&lt;p&gt;I started off the day by hearing from my buddy, &lt;a title="Mark Provan" target="_blank" href="http://forrst.com/people/markprovan"&gt;Mark Provan&lt;/a&gt;, that the offer to continue at his internship had been withdrawn due to financial complications at the company.  Without delving into Mark&amp;#8217;s personal life, he was relying on this job to maintain his way of life and was rather (understandably) upset by the whole ordeal.  I must say I&amp;#8217;m astounded that he never lost his cool and kept good spirits about it despite being rather stressed.  &lt;/p&gt;
&lt;p&gt;In an effort to secure funds for he and his girlfriend he &lt;a title="Abandoned Forrster" target="_blank" href="http://forrst.com/posts/Abandoned_Forrstr_Seeks_New_Employer-vyV"&gt;reached out to the Forrst community&lt;/a&gt; for help in locating any freelance work, job positions, or advice people could offer.  Just minutes after Mark tweeted about his post, Forrst retweeted him, instantly boosting Mark&amp;#8217;s morale.  &lt;/p&gt;
&lt;p&gt;Within an hour or two, Mark had several replies offering advice, help, and positions.  He almost had an &lt;a title="Novel, son!" target="_blank" href="http://forrst.com/posts/Abandoned_Forrstr_Seeks_New_Employer-vyV#comment-435772"&gt;entire novel&lt;/a&gt; of help and advice written by my friend and coworker, &lt;a title="Jon-Paul aka t4nked/Rumbrook" target="_blank" href="http://forrst.com/people/t4nkd"&gt;Jon-Paul Lussier (t4nkd)&lt;/a&gt;.  By the time he left work today he was pretty positive he was going with one of the offers.&lt;/p&gt;
&lt;p&gt;I was outright astounded how awesome people, and the community as a whole, responded to a fellow member in need.  Mark is an great and humble guy and really it couldn&amp;#8217;t have happened to a better person.  I just wanted to make sure that this display of community and helpfulness was not completely overlooked by the masses, and I could at least spread it to my followers on twitter and visitors to my blog.  This is what a community should be, and am incredibly proud of what I witnessed today.&lt;/p&gt;
&lt;p&gt;Thank you, everyone :)&lt;/p&gt;</description><link>http://matthewmachuga.com/post/10192275786</link><guid>http://matthewmachuga.com/post/10192275786</guid><pubDate>Tue, 13 Sep 2011 23:56:15 -0400</pubDate></item><item><title>Protect the Environment! - The Terminal and Editor</title><description>&lt;h3&gt;Computers and Operating Systems&lt;/h3&gt;
&lt;p&gt;As noted, all of my machines are Macs and most are already on Lion, the remainder will be in the near future.  Aside from a few spinning beach ball issues, not being able to run two fullscreen apps simultaneously with dual monitors, and a very frustrating heating issue since updating, I&amp;#8217;m very happy with Lion.  The upgrade process seemed to bork a few of my PHP and Apache settings, but I will grant Lion a pass on that because readline support comes compiled in the system PHP.  Any complications I&amp;#8217;m experiencing I am considering part of the &amp;#8220;Early Adopter Tax&amp;#8221; and will ignore those for the time being.  I came from a Linux background and still spend a lot of time in the command line, so as long as I have a *nix environment I&amp;#8217;m generally happy.  I appreciate the aesthetics, ease of use, font rendering, application selection, power, and shortcuts OS X provides me in all aspects of computing so I will not be altering my machines or operating systems with the sole exception of inverting the scrolling on the remaining Snow Leopard machine with Scroll Reverser.&lt;/p&gt;
&lt;h3&gt;Terminal Emulator&lt;/h3&gt;
&lt;p&gt;While Terminal.app has been improved and seems to have drastically improved 256-color support, I&amp;#8217;m still not sure it&amp;#8217;s for me.  I don&amp;#8217;t really care for the way split panes are handled after using iTerm2 for so long and it still has some oddball results with the solarized theme in Vim, so I will be sticking with iTerm2.  iTerm2 has the option to use Lion or standard fullscreen windows and after dabbling with the Lion fullscreen for a bit, I&amp;#8217;ve opted to keep the standard version because I generally have a web browser or something open with it on the other screen.  I also keep Left Option defined as my meta key by using the +Esc option, which gets rid of the headache of having to press it several times for different keystrokes.  I&amp;#8217;d also like to note that I use the Inconsolata font at 15pt because I find it extremely friendly to stare at for 8+ hours a day.  I still like Monoco, but just feel better with Inconsolata.&lt;/p&gt;
&lt;h3&gt;Terminal Environment&lt;/h3&gt;
&lt;p&gt;I&amp;#8217;m taking a deep breath and backing up all of my dotfiles as I&amp;#8217;m beginning this paragraph.  I&amp;#8217;m very comfortable with my current environment but this post is about change and optimizing&amp;#8230; so here we go!&lt;/p&gt;
&lt;pre&gt;mkdir ~/old_dotfiles/
mv .vimrc.local .zshrc ~/old_dotfiles/
mv .vim ~/old_dotfiles/.vim-janus # Backup Janus - not necessary, but will explain later
rm .vimrc .gvimrc # Destroy the symlinks   

&lt;/pre&gt;
&lt;p&gt;I&amp;#8217;m also going to be sure to place all of my dotfiles under a single directory and place it under version control (as I should&amp;#8217;ve from the get-go), so I&amp;#8217;ll create that now.&lt;/p&gt;
&lt;pre&gt;mkdir ~/Development/dotfiles &amp;amp;&amp;amp; cd ~/Development/dotfiles
mkdir vim &amp;amp;&amp;amp; mkdir vim/backup # vim/backup is where I store all my swap files
echo 'vim/backup' &amp;gt; .gitignore
git init 

&lt;/pre&gt;
&lt;p&gt;Alright, time to get to work while my previous .zshrc is still loaded in memory.&lt;/p&gt;
&lt;h3&gt;Shell&lt;/h3&gt;
&lt;p&gt;I&amp;#8217;m definitely sticking with ZSH - I&amp;#8217;ve grown to love it and it is largely Bash compatible so I&amp;#8217;m staying where I am.  I&amp;#8217;ve also decided to go with oh-my-zsh because people far smarter than I have put together a large collection of plugins and theme elements I can pick and choose from as I like; perfect as I&amp;#8217;m not a fan of shell scripting.  I&amp;#8217;m going to keep my theme too since I just got it the way I like it, so that can be the first real file in my new dotfiles directory.  I&amp;#8217;ll start a new .zshrc immediately after.&lt;/p&gt;
&lt;pre&gt;cp ~/.oh-my-zsh/themes/machuga.zsh-theme ~/Development/dotfiles/
vim ~/Development/dotfiles/zshrc 

&lt;/pre&gt;
&lt;p&gt;Oh hello vanilla Vim, haven&amp;#8217;t seen you in a little while.  The first thing I need to do is link up oh-my-zsh, then I can set my theme name, choose which plugins I want loaded, set some environment variables, load RVM, and then customize it to my liking with aliases and a few functions I found on the interwebs that I like.  This means pulling the subtle differences I may have on one machine and wish I&amp;#8217;ve had on all of them for a while.&lt;/p&gt;
&lt;p&gt;&lt;a title="Machuga's .zshrc" target="_blank" href="http://pastebin.com/y3PEFw9X"&gt;~/Development/dotfiles/zshrc&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Alright that looks good to me.  Most of the cruft is cut out except for that json tool, I kept that because I simply can&amp;#8217;t remember what it does.  I&amp;#8217;ll delete it if it winds up being useless.&lt;/p&gt;
&lt;h3&gt;Vim&lt;/h3&gt;
&lt;p&gt;Time to do some plucking!  This is why I kept Janus around - so I can pick and choose plugins without going out and downloading them individually.  Plus, I really like the Janus version of NERDTree.  Here are the ones plugins that made the cut into my ~/Development/dotfiles/vim/(plugin|autoload) directories:&lt;/p&gt;
&lt;pre&gt;AlignMapsPlugin.vim
AlignPlugin.vim
NERD_tree.vim
ZoomWinPlugin.vim
ack.vim
gist.vim
rails.vim
snipMate.vim
surround.vim
syntastic.vim
vim-rspec.rb
vim-rspec.vim
vim-rspec.xsl

&lt;/pre&gt;
&lt;p&gt;I also kept most of the syntaxes and colors around because I use a number of the extra syntaxes, and the colors just in case I ever get bored with solarized.  Next I&amp;#8217;m going to rip out the pieces I like of the default .vimrc that came with Janus and merge them with my .vimrc.local and add in a few extra lines, like setting Ruby files to 2-space tabbing. Now ~/Development/dotfiles/vimrc and ~/Development/dotfiles/gvimrc look like these:&lt;/p&gt;
&lt;p&gt;&lt;a title="Machuga's .vimrc" target="_blank" href="http://pastebin.com/LrfQuqj1"&gt;~/Development/dotfiles/vimrc&lt;/a&gt;&lt;br/&gt;&lt;a title="Machuga's .gvimrc" target="_blank" href="http://pastebin.com/Hue1beb1"&gt;~/Development/dotfiles/gvimrc&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Now that all of my dotfiles are generated, it&amp;#8217;s time to hook them up!&lt;/p&gt;
&lt;pre&gt;ln -s ~/Development/dotfiles/zshrc .zshrc
ln -s ~/Development/dotfiles/vimrc .vimrc
ln -s ~/Development/dotfiles/gvimrc .gvimrc
ln -s ~/Development/dotfiles/vim .vim
source ~/.zshrc

&lt;/pre&gt;
&lt;p&gt;ZSH is still intact and after a quick boot into both system Vim and MacVim, both are behaving as expected and aren&amp;#8217;t throwing the typical errors I occasionally get with Janus. Excellent, now I&amp;#8217;m a happy camper!  Now that this in place I&amp;#8217;m going to consider my terminal environment configured, commit my changes, and move onto the next piece.&lt;/p&gt;</description><link>http://matthewmachuga.com/post/8915080766</link><guid>http://matthewmachuga.com/post/8915080766</guid><pubDate>Sun, 14 Aug 2011 14:39:22 -0400</pubDate></item><item><title>Protect the Environment! - The Intro</title><description>&lt;p&gt;I&amp;#8217;ve recently come to a realization: my development environment is shit.  Okay, that&amp;#8217;s harsh and unfair to the tools.  In theory it&amp;#8217;s a fairly nice setup, but I generally add or allow too many distractions or extras, intended for convenience, overshadow my original intent.  A lot of what I use makes me more productive, but sometimes in conjunction with one another, my tools slow me down.  Some of my favorite tools have even begun to frazzle me and impede my development speed.  In other words - the problem is me and I&amp;#8217;ve done this to myself.  This is unacceptable and I believe it&amp;#8217;s time for a purge and restructure.  First, let me provide and outline of what I currently use, presented in no particular order:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;One personal iMac w/ Mac OS X Lion and oh-my-zsh&lt;/li&gt;
&lt;li&gt;One personal MacBook Pro w/ Mac OS X Lion and modified version of Gary Bernhardt&amp;#8217;s Z Shell&lt;/li&gt;
&lt;li&gt;One work Mac Mini with Mac OS X Snow Leopard w/ same modified Z Shell&lt;/li&gt;
&lt;li&gt;iTerm2&lt;/li&gt;
&lt;li&gt;Vim and MacVim w/ Janus&lt;/li&gt;
&lt;li&gt;TextMate for viewing large project trees&lt;/li&gt;
&lt;li&gt;Mail.app&lt;/li&gt;
&lt;li&gt;Three different active email accounts w/ some structured directory systems&lt;/li&gt;
&lt;li&gt;irssi&lt;/li&gt;
&lt;li&gt;Campfire&lt;/li&gt;
&lt;li&gt;iChat&lt;/li&gt;
&lt;li&gt;Google Chrome&lt;/li&gt;
&lt;li&gt;Firefox on occasion&lt;/li&gt;
&lt;li&gt;RVM&lt;/li&gt;
&lt;li&gt;System install PHP 5.3&lt;/li&gt;
&lt;li&gt;PHPUnit w/ Selenium&lt;/li&gt;
&lt;li&gt;A few random Pear libraries&lt;/li&gt;
&lt;li&gt;Apache 2 (upgraded from Snow Leopard)&lt;/li&gt;
&lt;li&gt;Unversioned dot files (stored in Dropbox sometimes) all in their default locations&lt;/li&gt;
&lt;li&gt;Git&lt;/li&gt;
&lt;li&gt;Git Flow&lt;/li&gt;
&lt;li&gt;Git Diff&lt;/li&gt;
&lt;li&gt;Homebrew&lt;/li&gt;
&lt;li&gt;Xcode/GCC&lt;/li&gt;
&lt;li&gt;Remapped Caps Lock to Control&lt;/li&gt;
&lt;li&gt;MySQL&lt;/li&gt;
&lt;li&gt;Starting with Tmux&lt;/li&gt;
&lt;li&gt;Sequel Pro&lt;/li&gt;
&lt;li&gt;Manual deployment on all current projects&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Other than a few glaring issues it doesn&amp;#8217;t seem like a bad environment, and for all intents and purposes it&amp;#8217;s certainly not.  However, as I mentioned before I feel like certain things are getting in my way more than they are helping anymore, and I&amp;#8217;d really like to simplify, standardize, optimize, and automate my environments as a whole.  I&amp;#8217;ve nabbed some good ideas from my coworkers, some podcasts, and from a recent &lt;a title="ThoughtBot ftw" target="_blank" href="http://robots.thoughtbot.com/post/8700977975/2011-rubyists-guide-to-a-mac-os-x-development"&gt;thoughbot blog post&lt;/a&gt; and ultimately thought out a few ways I&amp;#8217;d like to see things done.  I figured I&amp;#8217;d document it here so others may benefit from it or recommend better options to me. &lt;/p&gt;
&lt;p&gt;After I started writing this, I realized this would be better to break up into multiple posts because it can become rather lengthy.  I&amp;#8217;ll start post chunk by chunk so you can read through whatever posts interest you and skip the rest.&lt;/p&gt;</description><link>http://matthewmachuga.com/post/8915069487</link><guid>http://matthewmachuga.com/post/8915069487</guid><pubDate>Sun, 14 Aug 2011 14:39:04 -0400</pubDate></item><item><title>CodeIgniter-Filter Revisited</title><description>&lt;p&gt;Link to code on GitHub: &lt;a title="http://bit.ly/lZuAHq" target="_blank" href="http://bit.ly/lZuAHq"&gt;&lt;a href="http://bit.ly/lZuAHq" target="_blank"&gt;http://bit.ly/lZuAHq&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;A little less than a year ago I released a hook for before/after filters in CodeIgniter.  Since I&amp;#8217;ve built a few more apps recently in CI I&amp;#8217;ve revisited the implementation of my library and swiftly arrived at the conclusion &amp;#8220;This is such a waste&amp;#8221;.  I was never fond of the idea of being locked into using public methods (the methods needed to be visible to the Filter class) as I wholeheartedly believe in keeping objects encapsulated and abstracted properly.  Of course with CodeIgniter, prepending an underscore to a method name will infact prevent the router from calling it, but I find it sloppy and very PHP4ish.  Snarky, I know, but it&amp;#8217;s how I feel.&lt;/p&gt;
&lt;p&gt;Solution: What I should&amp;#8217;ve done in the first place.  I&amp;#8217;ve moved everything into a base controller where before_filter() is called before every action, and after_filter() is, you guessed it, called after every action.  If you don&amp;#8217;t have any actions set in that filter type, it will simply pass through normally.&lt;/p&gt;
&lt;h3&gt;Example&lt;/h3&gt;
&lt;pre&gt;&lt;code class="php"&gt;&amp;lt;?php 

class Home extends MY_Controller {

  protected $before_filter = array(
    'action' =&amp;gt; 'redirect_if_not_logged_in',
    'except' =&amp;gt; array('index')
  );

  public function index() {
    echo 'You can see me because you won\'t be redirected!';
  }

  public function method_requiring_authentication() {
    echo 'Unless you\'re logged in, you\'ll never see me :(';
  }

  // Example callback

  protected function redirect_if_not_logged_in() {
    $this-&amp;gt;load-&amp;gt;library('Authentic');
    if ( ! $this-&amp;gt;authentic-&amp;gt;logged_in()) {
      redirect(site_url('login'));
    }
  }
}
?&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the above example, if someone tries to go to the &amp;#8220;method_requiring_authentication&amp;#8221; page, the before_filter callback &amp;#8220;redirect_if_not_logged_in&amp;#8221; will be called prior to the action.  If the user is logged in using the Authentic library, the callback will return and the action will be called as normal.  If the user is not logged in, they will be redirected to the &amp;#8216;login&amp;#8217; page.  &lt;/p&gt;
&lt;p&gt;Redirects are not the only use for filters.  If you come from the Rails world, you likely know that they are also extremely handy for removing repeated code involving resources.&lt;/p&gt;
&lt;h3&gt;Instead of:&lt;/h3&gt;
&lt;pre&gt;&lt;code class="php"&gt;&amp;lt;?php 

class User extends MY_Controller {

  protected $before_filter = array(
    'action' =&amp;gt; 'redirect_if_not_logged_in',
    'except' =&amp;gt; array('index')
  );

  public function __construct() {
    $this-&amp;gt;load-&amp;gt;spark('php-activerecord/0.0.1');
  }

  public function index() {
    $users = User:all();
  }

  public function show($id) {
    $user = User::find($id);
    // Logic
  }

  public function add() {
    $user = new User;
    // Logic
  }
  public function create() {
    $user = new User;
    // Logic
  }

  public function edit($id) {
    $user = User::find($id);
    // Logic
  }

  public function update($id) {
    $user = User::find($id);
    // Logic
  }

  public function destroy($id) {
    $user = User::find($id);
    // Logic
  }

  public function method_requiring_authentication() {
    echo 'Unless you\'re logged in, you\'ll never see me :(';
  }
}
?&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;We can have:&lt;/h3&gt;
&lt;pre&gt;&lt;code class="php"&gt;&amp;lt;?php 

class User extends MY_Controller {

  protected $before_filter = array(
    'action' =&amp;gt; 'redirect_if_not_logged_in',
    'except' =&amp;gt; array('index')
  );

  public function __construct() {
    $this-&amp;gt;load-&amp;gt;spark('php-activerecord/0.0.1');
  }

  public function index() {
    $this-&amp;gt;users = User::all();
  }

  public function show($id) {
    // Important logic without repeated code
  }

  public function add() {
    // Important logic without repeated code
  }

  public function create() {
    // Important logic without repeated code
  }

  public function edit($id) {
    // Important logic without repeated code
  }

  public function update($id) {
    // Important logic without repeated code
  }

  public function destroy($id) {
    // Important logic without repeated code
  }

  public function method_requiring_authentication() {
    echo 'Unless you\'re logged in, you\'ll never see me :(';
  }

  // Example callback

  protected function get_resource($params = array()) {
    $id = $params[0];  // Set the ID parameter
    try {
      $this-&amp;gt;user = in_array($this-&amp;gt;router-&amp;gt;method(), array('show', 'edit', 'update', 'destroy')) ? User::find($id) : new User;
    } catch (Exception $e) {
      $this-&amp;gt;session-&amp;gt;set_userdata('error', 'This user does not exist!');
      redirect('users/index');
    }
  }
}
?&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Look at that!  We were even able to throw in code for handling an exception that PHPActiveRecord throws if the ID doesn&amp;#8217;t exist in only 7 lines of code! (side note: find_by_id() doesn&amp;#8217;t throw an exception if you&amp;#8217;d like to handle it without exceptions.)&lt;/p&gt;
&lt;p&gt;Hopefully more of you can get some use out of this library with the added functionality.  I really just needed more functionality to solve my problems, and I think the code is much more useful and concise now.&lt;/p&gt;
&lt;p&gt;Let me know if you can think of any improvements! &lt;/p&gt;
&lt;p&gt;Again, here&amp;#8217;s the link to the code on GitHub: &lt;a title="http://bit.ly/lZuAHq" target="_blank" href="http://bit.ly/lZuAHq"&gt;&lt;a href="http://bit.ly/lZuAHq" target="_blank"&gt;http://bit.ly/lZuAHq&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;</description><link>http://matthewmachuga.com/post/7181182435</link><guid>http://matthewmachuga.com/post/7181182435</guid><pubDate>Sun, 03 Jul 2011 00:38:00 -0400</pubDate></item><item><title>Hellou Matthew, I'm just starting a new CodeIgniter project and I'm thinking about using your php-activerecord spark. Should I take care of something here around? Are there some disadvantages of using this connection? What about performance?&lt;br /&gt;&#13;
Thank you!</title><description>&lt;p&gt;Hello!  There aren’t really many disadvantages to using the spark - it’s actually rather convenient.  There is a negligible overhead of instantiating an extra object for the boostrapper, along with loading every file in the config immediately instead of autoloading as I have in my tutorial ( I did this to keep the default PHPActiveRecord loader intact.  It should still be negligible.  All you should need to do is load the spark anywhere you choose to use it :)&lt;/p&gt;
&lt;p&gt;Let me know if you run into any issues!&lt;/p&gt;</description><link>http://matthewmachuga.com/post/5833783986</link><guid>http://matthewmachuga.com/post/5833783986</guid><pubDate>Wed, 25 May 2011 10:57:16 -0400</pubDate></item><item><title>Hi - Wanted to say this was a great post! Some really great information. I had wanted to post a comment, but I don't think you have them activated...&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I saw a couple of nits I hope you don't mind me pointing out... I just thought I'd mention them because currently you're one the best sources that comes up from googling "codeigniter php-activerecord" and I wanted to 'give back' for the time you took to write and post this!&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
1) with the newest version of codeigniter line #10 in Activerecord.php should be: "require_once BASEPATH.'/core/Model.php';"&lt;br /&gt;&#13;
2) the newest version of codeigniter changed their controller class to CI_Controller so the example for 2.0 should probably be "class Users extends CI_Controller {"&lt;br /&gt;&#13;
3) in the example you gave at the end of your post I think there's a colon missing "$userthree = User:find(3);"&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Thanks, once again! You saved me a lot of work in integrating this! If it weren't for your article, I never would have started using php-activerecord.</title><description>&lt;p&gt;Thanks for the kind words and assistance!  Ya that post was written back when 2.0b was still out, prior to the CI_ name change.  I’ll need to add that warning in there - thanks!  Also, thanks for the flaring typo there :)&lt;/p&gt;
&lt;p&gt;As for #1, you can completely remove this - it’s an unnecessary line I didn’t realize wasn’t used for a bit.  If you’d like to check it out, the newest article is far more up to date (and optimized) and I also have a spark of this available at http://getsparks.org/packages/php-activerecord/versions/HEAD/show.&lt;/p&gt;
&lt;p&gt;Hope that helps you further :)   Thanks again.&lt;/p&gt;</description><link>http://matthewmachuga.com/post/5395266378</link><guid>http://matthewmachuga.com/post/5395266378</guid><pubDate>Wed, 11 May 2011 14:08:18 -0400</pubDate></item><item><title>Revised: PHP.ActiveRecord + CodeIgniter 2.0 Reactor 2.0+</title><description>&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This post is essentially an update to my previous post a few months back, but I revamped it for a few good reasons.  The main reason is that CodeIgniter Reactor is a bit different from the old 1.7.x Core branch, and a secondary reason being that I hacked the last one together in a very hasty manner for a project I needed to complete.  Since then I&amp;#8217;ve refined the process a bit and it should not only be more reliable, but also be a bit faster as it aleves some overhead.&lt;/p&gt;
&lt;p&gt;Alright, let&amp;#8217;s get started!&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;Grab the nightly build of &lt;a title="PHP.ActiveRecord" target="_blank" href="http://phpactiverecord.com"&gt;PHP.ActiveRecord&lt;/a&gt; (the stable release is severely out-of-date and lacks several features and bugfixes mentioned in the documentation.&lt;/li&gt;
&lt;li&gt;Grab a copy of CodeIgniter Reactor 2.0+ from &lt;a title="CodeIgniter Home Page" target="_blank" href="http://codeigniter.com"&gt;CodeIgniter.com&lt;/a&gt; or their BitBucket page.&lt;/li&gt;
&lt;li&gt;Extract your CodeIgniter installation and move it into your web server&amp;#8217;s directory&lt;/li&gt;
&lt;li&gt;Extract PHP.ActiveRecord into your ./application/third_party directory.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;This is where we astray from the previous method and make this implementation a bit more CodeIgniter-like.&lt;/p&gt;
&lt;p&gt;In ./application/config/config.php, change:&lt;/p&gt;
&lt;pre&gt;&lt;code class="php"&gt;$config['enable_hooks'] = FALSE; &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;to&lt;/p&gt;
&lt;pre&gt;&lt;code class="php"&gt;$config['enable_hooks'] = TRUE;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;then close it out.  This will allow hooks to be called in your application, and our next step requires this.  Open ./application/config/hooks.php and add the following:&lt;/p&gt;
&lt;pre&gt;&lt;code class="php"&gt;$hook['pre_controller'][] = array(
    'class'    =&amp;gt; '',
    'function' =&amp;gt; 'initialize_php_activerecord',
    'filename' =&amp;gt; 'ActiveRecord.php',
    'filepath' =&amp;gt; 'third_party/php-activerecord'                                
);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This adds a hook to the CodeIgniter initialization that will call the &amp;#8220;initialize_php_activerecord&amp;#8221; function just before the controller constructor is called to ensure our models are available if needed.  We&amp;#8217;re going to create that function next and add some autoloading magic that will keep true to the &amp;#8220;load only what you need&amp;#8221; mentality of CodeIgniter.&lt;/p&gt;
&lt;p&gt;Open up ./application/third_party/php-activerecord/ActiveRecord.php and swap out the existing code with the following:&lt;/p&gt;
&lt;pre&gt;&lt;code class="php"&gt;&amp;lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

function initialize_php_activerecord() {
    if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID &amp;lt; 50300)
        die('PHP ActiveRecord requires PHP 5.3 or higher');

    define('PHP_ACTIVERECORD_VERSION_ID','1.0');

    // This constant allows you to prepend your file to the autoload stack rather than append it.
    if (!defined('PHP_ACTIVERECORD_AUTOLOAD_PREPEND')) {
        define('PHP_ACTIVERECORD_AUTOLOAD_PREPEND',true);
    }

    // This line simply states that if we haven't opted to disable the autoloader, add it to the autoload stack
    if (!defined('PHP_ACTIVERECORD_AUTOLOAD_DISABLE')) {
        // Because we're prepending - we need to load the library after the models
        spl_autoload_register('activerecord_autoload', false, PHP_ACTIVERECORD_AUTOLOAD_PREPEND);
        spl_autoload_register('activerecord_lib_autoload', false, PHP_ACTIVERECORD_AUTOLOAD_PREPEND);
    }

    // The Utils.php file has some namespaced procedural functions, so we must require it manually.
    require 'lib/Utils'.EXT;

    // Include the CodeIgniter database config so we can access the variables declared within
    include(APPPATH.'config/database'.EXT);

    $dsn = array();
    if ($db) {
        foreach ($db as $name =&amp;gt; $db_values) {
            // Convert to dsn format
            $dsn[$name] = $db[$name]['dbdriver'] .
                '://'   . $db[$name]['username'] .
                ':'     . $db[$name]['password'] .
                '@'     . $db[$name]['hostname'] .
                '/'     . $db[$name]['database'];
        }
    } 

    // Initialize ActiveRecord
    ActiveRecord\Config::initialize(function($cfg) use ($dsn, $active_group){
        $cfg-&amp;gt;set_model_directory(APPPATH.'models');
        $cfg-&amp;gt;set_connections($dsn);
        $cfg-&amp;gt;set_default_connection($active_group);
    });
}


function activerecord_lib_autoload($class_name)
{
    $lib_path = APPPATH.'third_party/php-activerecord/lib/';

    if (strpos($class_name, 'ActiveRecord') !== FALSE) 
    {
        $class = substr($class_name, strpos($class_name, '\\')+1);

        if (file_exists($lib_path.$class.EXT))
            require $lib_path.$class.EXT;
    }
}

function activerecord_autoload($class_name)
{
    $path = ActiveRecord\Config::instance()-&amp;gt;get_model_directory();
    $root = realpath(isset($path) ? $path : '.');

    if (($namespaces = ActiveRecord\get_namespaces($class_name)))
    {
        $class_name = array_pop($namespaces);
        $directories = array();

        foreach ($namespaces as $directory)
            $directories[] = $directory;

        $root .= DIRECTORY_SEPARATOR . implode($directories, DIRECTORY_SEPARATOR);
    }

    $file = "$root/$class_name".EXT;

    if (file_exists($file))
        require $file;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;At this point, PHP.ActiveRecord is ready for use with CodeIgniter 2.0.  I will certainly admit this is not the simplest way ever to add in PHP.ActiveRecord, but there are many people who reject doing a simple include() (for whatever reason) in CodeIgniter, so I kept up with traditional CodeIgniter idioms as much as possible while still getting what I want from the whole thing.  I personally am rather satisfied with this solution, but if you have your own opinions on it, feel free to let me know.&lt;/p&gt;
&lt;p&gt;Next post I&amp;#8217;m going to go over keeping your controllers DRY with PHP.AR and CI, including some info on model-based validations over CI validations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I&amp;#8217;ve also released a Spark for this functionality to be quickly added to a CodeIgniter install.  It matches the first implementation much more closely and is not as optimized as the solution I&amp;#8217;ve just explained, but you can&amp;#8217;t beat it&amp;#8217;s setup speed (php tools/spark install php-activerecord.  DONE!).  Check it out here: &lt;a href="http://getsparks.org/packages/php-activerecord/versions/HEAD/show" target="_blank"&gt;php-activerecord on getsparks.org&lt;/a&gt;&lt;/p&gt;</description><link>http://matthewmachuga.com/post/4571278653</link><guid>http://matthewmachuga.com/post/4571278653</guid><pubDate>Tue, 12 Apr 2011 23:15:00 -0400</pubDate></item><item><title>Adding PHP.ActiveRecord to a CodeIgniter App</title><description>&lt;p&gt;At some point last week (or two?) I posted to Forrst about setting up &lt;a title="PHP.ActiveRecord" target="_blank" href="http://www.phpactiverecord.org/"&gt;PHP.ActiveRecord&lt;/a&gt; in a CodeIgniter App.  It was rather brief and most of my documentation was thrown into code comments, so I wanted to do a proper write-up here.  Let&amp;#8217;s start with the basics.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;What is PHP.ActiveRecord?&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;PHP.ActiveRecord, as started on their site, &amp;#8220;is an open source ORM library based on the ActiveRecord pattern.&amp;#8221;  This library was largely inspired by Ruby on Rails&amp;#8217; implementation of ActiveRecord, an element that is very much welcomed by myself and hopefully many others.  The majority of the implementation from Rails is present, and I have yet to stumble upon a feature that is missing that is actually needed (I found one or two small things missing in regards to self-referential relationships that PHP.AR had compensated for in an easier way).  It should also be noted that this library needs PHP 5.3 or higher to run due to extensive use of late-static binding and the occasional anonymous functions and closures here and there.&lt;/p&gt;

&lt;h3&gt;&lt;strong&gt;Why PHP.ActiveRecord?&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;I&amp;#8217;ll be honest in saying I&amp;#8217;ve never actually used another PHP ORM prior to this.  The most experience outside of straight SQL through a DB driver I&amp;#8217;ve had is utilizing CodeIgniter&amp;#8217;s ActiveRecord class.  That being said, I&amp;#8217;ve been following Doctrine for a while now and while I greatly respect what they&amp;#8217;ve done I&amp;#8217;m not sure it&amp;#8217;s right for me at this point.  I go back and forth between Rails and PHP a lot so I&amp;#8217;d prefer to keep one set of concepts and conventions that I already use and like.  In addition, I like not having to tell the ORM what my db tables are - PHP.ActiveRecord can detect tables appropriately if you have your model prototyped.  Another large bonus of PHP.ActiveRecord was that it looked incredibly simple to plug into CodeIgniter, which is the framework on which SocialKloud is built.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;Integrating with CodeIgniter&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Here is what you need to get started:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;Grab a fresh download of &lt;a title="PHP.ActiveRecord" target="_blank" href="http://www.phpactiverecord.org/download"&gt;PHP.ActiveRecord&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Grab a fresh &lt;a title="CodeIgniter" target="_blank" href="http://codeigniter.com"&gt;CodeIgniter&lt;/a&gt; installation or use a pre-existing one ( this walkthrough applies to both 1.7.2 and 2.0b )&lt;/li&gt;
&lt;li&gt;Extract PHP.ActiveRecord and move the &amp;#8220;php-activerecord&amp;#8221; directory to your CI installation&amp;#8217;s &amp;#8220;application/libraries&amp;#8221; directory&lt;/li&gt;
&lt;li&gt;(Optional) Remove any of the extraneous files you don&amp;#8217;t wish to keep&lt;/li&gt;
&lt;li&gt;In &amp;#8220;application/config/autoload.php&amp;#8221;, under the $autoload[&amp;#8216;libraries&amp;#8217;] array, add &amp;#8216;activerecord&amp;#8217; and optionally remove.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;Create a file in &amp;#8220;applications/libraries&amp;#8221; named &amp;#8220;Activerecord.php&amp;#8221; to act as the bootstrapper for PHP.ActiveRecord, then copy/paste the following code snippet to that file: &lt;/p&gt;
&lt;p&gt;Activerecord.php:&lt;/p&gt;
&lt;pre class="brush: php"&gt;&amp;lt;?php
/**
* Init for php.activerecord
*/

// Load php.activerecord
require_once APPPATH.'/libraries/php-activerecord/ActiveRecord.php';

// Load CodeIgniter's Model class 
require_once BASEPATH.'/libraries/Model.php';

class Activerecord {
    
    function __construct() {
        // Load database configuration from CodeIgniter
        include APPPATH.'/config/database.php';
        // Get connections from database.php
        $dsn = array();
        if ($db) {
            foreach ($db as $name =&amp;gt; $db_values) {
            	// Convert to dsn format
            	$dsn[$name] = $db[$name]['dbdriver'] .
            		'://'   . $db[$name]['username'] .
            		':'     . $db[$name]['password'] .
            		'@'     . $db[$name]['hostname'] .
            		'/'     . $db[$name]['database'];
            }
        } 
        
        // Initialize ActiveRecord
        ActiveRecord\Config::initialize(function($cfg) use ($dsn, $active_group){
            $cfg-&amp;gt;set_model_directory(APPPATH.'/models');
            $cfg-&amp;gt;set_connections($dsn);
            $cfg-&amp;gt;set_default_connection($active_group);
        });
        
    }
}

/* End of file Activerecord.php */
/* Location: ./application/libraries/Activerecord.php */&lt;/pre&gt;
&lt;p&gt;Congratulations!  PHP.ActiveRecord is now ready for use!&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;Things to Note&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;When putting models in your &amp;#8220;models&amp;#8221; folder, you can no longer append &amp;#8220;_model&amp;#8221; to each filename.  Simply name it after your model.  (Note: You can, but you have to tweak a line the ActiveRecord&amp;#8217;s loader.)&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;Let&amp;#8217;s say you have a basic db table named `users` with `username` and `name` and `password` not null fields all as varchar(100).&lt;/p&gt;
&lt;p&gt;You would setup your model declaration in a file named User as:&lt;/p&gt;
&lt;pre class="brush: php"&gt;&amp;lt;?php
class User extends ActiveRecord\Model {
    
}
&lt;/pre&gt;
&lt;p&gt;This little snippet allows you to use the following code in your controllers as such:&lt;/p&gt;
&lt;pre class="brush: php"&gt;&amp;lt;?php
class Users extends Controller {
    function index() {
        // Find all users
        $all_users = User::all(); // or User:find('all')

        // Find user with id of 3
        $userthree = User:find(3); // or User:find_by_id(3)

        // Find user with username 'codemonkey'
        $codemonkey = User::find_by_username('codemonkey');

    }
}
&lt;/pre&gt;
&lt;p&gt;There are tons of other things you can do with this ORM, check &lt;a title="PHP.ActiveRecord" target="_blank" href="http://phpactiverecord.org"&gt;their site&lt;/a&gt; for more information.&lt;/p&gt;
&lt;p&gt;Hopefully that helped some of you integrate PHP.ActiveRecord into your CodeIgniter project, or inspired other to give it a shot.  If you have any questions/comments/concern, please post them in the comments.&lt;/p&gt;</description><link>http://matthewmachuga.com/post/871550737</link><guid>http://matthewmachuga.com/post/871550737</guid><pubDate>Wed, 28 Jul 2010 14:03:00 -0400</pubDate><category>php</category><category>phpactiverecord</category><category>orm</category><category>codeigniter</category><category>tutorial</category><category>socialkloud</category></item><item><title>Do Phoenixes Have Ghosts? (The Tale of a Community)</title><description>&lt;p&gt;&lt;strong&gt;The Past:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Shortly after Pownce closed it&amp;#8217;s doors in December of 2008, a former Pownce member  named Joel (!mathamoz) opened up a replacement site entitled Topixz for all Pownce refugees.  As the community was slowly building, Joel was forced to change the name of the social network to SocialKloud due to trademark issues.  The community was small, but was welcoming and caring.  Discussion topics were generally in the nerdy and artsy veins, but the diversity was present.  The positive atmosphere was kept alive by the members, Joel, and the community manager, Amber (!caliblondie).  It felt like Pownce, and to some of us I believe it felt even more like a family than before.&lt;/p&gt;
&lt;p&gt;After a few months where updates would become less and less frequent, Joel asked for someone to take over the site.  He had approached me via a Private Message asking if I&amp;#8217;d be interested, noticing I had dabbled in the same framework SK was built upon.  I (!machuga) happily replied, &amp;#8220;Sure&amp;#8221; and acquired the source code.  Due to conflicts with my own projects and finishing college, I was unable to re-launch my own version of the site.  At the same time, Mark Provan (!markprovan) was talking with Joel as well about relaunching the site.  He too, unfortunately, wasn&amp;#8217;t able to re-launch.  By the next week, Joel closed the doors on SocialKloud and seemingly disappeared off the face of the Earth.  Mark, Amber, and myself had been unable to make contact with Joel since (up until I was half way done writing this post, no joke).  It&amp;#8217;s a shame we lost contact with him because he was an awesome and very intelligent guy, let alone being an excellent social network leader/developer.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Present:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If my memory serves me correctly, SocialKloud has been closed for just over a year now.  A handful of members from the old community have kept in touch via Twitter and/or other networks, and we continue to talk as if it was just like when SK was still around.  Several posts appear on Twitter from week from former Powncers who long for their home and community back.  Many of us who keep in touch still discuss how we want Pownce and SK back as well, or miss certain aspects of each.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Future:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now that you&amp;#8217;ve had a history lesson, I suppose I&amp;#8217;ll get to the point.&lt;/p&gt;
&lt;p&gt;As of late, Mark has taken it upon himself to begin the relaunch of SocialKloud, under the same moniker.  Seeing his efforts I began to offer my help and that eventually led to my direct involvement and commit access in the repo.  So I am proud to say that Mark, Amber, and myself are working to build the platform and community we once knew and loved, but with it&amp;#8217;s own individual vibe and goals.  &lt;/p&gt;
&lt;p&gt;Mark&amp;#8217;s new design for the site looks amazing and very welcoming, so I&amp;#8217;m hoping everyone will feel right at home again.  I&amp;#8217;ve been making some core adjustments and both Mark and I will now be working on some actual functionality. &lt;/p&gt;
&lt;p&gt;It is our hope we can keep a home for our community together this time :)&lt;/p&gt;</description><link>http://matthewmachuga.com/post/835030624</link><guid>http://matthewmachuga.com/post/835030624</guid><pubDate>Tue, 20 Jul 2010 01:15:00 -0400</pubDate><category>socialkloud</category><category>sk</category><category>social network</category><category>pownce</category></item><item><title>Tumblr == Home</title><description>&lt;p&gt;Today I&amp;#8217;ve made it official that Tumblr is now the host of my site/blog.  Am I taking the cheap and easy way out?  You bet!  Truthfully I had the whole site done in Ruby, but figured that to keep it simple myself (and editable from my iPhone). I&amp;#8217;d simply use a boxed solution and customize it as I want.  Originally I had gone with WordPress, but honestly just don&amp;#8217;t feel like messing with more PHP after spending 8hrs/day with it at work.  &lt;/p&gt;
&lt;p&gt;Tumblr does exactly what I want for the time being so I am more than satisfied with my decision.  &lt;/p&gt;
&lt;p&gt;The blog will be treated like any other blog - I&amp;#8217;ll post whatever I find interesting and maybe write out articles here if I feel the need to share a formally written opinion.  There will also be information involving any projects I&amp;#8217;m currently involved in, code snippets, etc.  It&amp;#8217;s a blog and it&amp;#8217;s 2010, you know what to expect!&lt;/p&gt;</description><link>http://matthewmachuga.com/post/704810684</link><guid>http://matthewmachuga.com/post/704810684</guid><pubDate>Wed, 16 Jun 2010 12:03:00 -0400</pubDate></item><item><title>Giving Tumblr a Test</title><description>&lt;p&gt;Thought I&amp;#8217;d check out Tumblr as a host for my personal site instead of using WordPress or custom coding it.  Looks possible&amp;#8230;hmmm&amp;#8230;&lt;/p&gt;</description><link>http://matthewmachuga.com/post/656686488</link><guid>http://matthewmachuga.com/post/656686488</guid><pubDate>Wed, 02 Jun 2010 09:53:00 -0400</pubDate></item></channel></rss>

