Chris’ Brain – May 2009 Edition

Book Update

For those not following along on Twitter, the first month of sales of my CakePHP book have been a success: 70 PDF's and 5 print-on-demand copies via Lulu.com. A big thanks to everyone who has purchased a copy. My next thought has been a book about doing Test Driven Development using CakePHP, but perhaps that is just wishcasting.

Deployment Thoughts

At work I've been tweaking the deployment process for an open source project that talks to our infrastructure and came upon an interesting problem. Like many projects, we have some configuration files that would be different from environment to environment (i.e. different database access credentials, paths to archived files) so we've chosen to instead create sample versions of those configuration files and include them in the application when you either download it (as external clients of ours do) or update from SVN (like we do).

Since I like to use Capistrano to do deployment, I needed a way to make sure that the configuration files that are currently being used by the application get copied into the proper place. Lucky for me, it was easy enough to add this in as a task in my Capfile:
PLAIN TEXT
RUBY:

  1. # Do nothing (To restart apache, run 'cap deploy:apache:restart')
  2.   task :restart do
  3.     run "cp /var/www/settings/sportscaster/gateway/php/config.php #{deploy_to}/current/gateway/php"
  4.     run "cp /var/www/settings/sportscaster/gateway/php_ci/config/gateway.config.php #{deploy_to}/current/gateway/php_ci/config"
  5.     run "cp /var/www/settings/sportscaster/engine/_application/config/database.php #{deploy_to}/current/engine/_application/config"
  6.     run "cp /var/www/settings/sportscaster/engine/_application/config/config.php #{deploy_to}/current/engine/_application/config"
  7.   end

As you can see, I've placed the configuration files in their own directory (off the web root I know, might make more sense to put them some place else but they can live there for now) and then simply copy them in place once I've deployed the latest code. I'd be interested in seeing how other people handle this issue.

Getting paid to do open source work

I feel like I'm very fortunate to have an employer who (mostly for business reasons) has decided to make some of their projects open source so that others can use it without cost. Sure, some of it is niche software to be sure (a web service that only works with our pay-to-use infrastructure) but still, d00d, I'm getting paid to write open source code! We also have another project in the works, helping these guys create a newer, more generic version of their fantasy league management application that has hooks to allow users to pull in data from our own web services. Sure, it's helping to drive our business but isn't that the point? I create something that helps my company make money, and in exchange I get to share it with everyone else. Sounds like a pretty good deal to me.