Hi. I’m Jeremy. I’m a web nerd.
And you’ll love me.
I write. I code. And make a mean martini.

Say hello.

Book Review: CodeIgniter 1.7 Professional Development

I was recently asked to review Packt Publishing’s new book, CodeIgniter 1.7: Professional Development, by fellow CodeIgniter community member, Adam Griffiths. Adam is a well-known developer in the CI community, who, despite his young age, has become well-known among the ranks of  CodeIgniter developers with his open source contributions.

I’m always excited to see new CodeIgniter books published, as the framework is growing in popularity and credibility among PHP developers, with applications springing up across the Internet. The framework is known for its excellent user guide and a strong community backing. But sometimes the resources available aren’t quite enough to make the concepts click in a new developer’s mind.

For me, the process involved viewing some of the available screencasts and looking at code that other had written in their applications. It wasn’t hard, but Adam’s new book would have been helpful to me in those early days of development with CodeIgniter. A selection of other CI-focused books have been published in the past, but I haven’t found many to be as practical as Adam’s. In previous books, often a single sample project is selected and used throughout the book to explain all of the concepts.

Adam’s approach is quite different and takes a look at various pieces of functionality that application developers might find very useful, while not walking them through the entire process of building an example application.

Specifically, Adam’s examples of using Twitter and Facebook authentication as well as accessing RESTful web services prove very useful, as these functions are increasingly at the core of many applications being built today.

The book also spends a bit of time talking about the basics of style in PHP coding. A guide like this would have helped to alleviate the evolution of coding style I’ve experienced as I’ve spent more and more time building web applications. It provides a solid baseline, referencing the CodeIgniter documentation’s style guide as a resource for maintaining code consistency.

Overall, I think that CodeIgniter 1.7: Professional Development fills a void in the market for CodeIgniter resources. I’d certainly recommend it to someone just starting out with the framework as an additional resource to use alongside the various other community resources.

The new book is not without its flaws though. As good as it is at helping a new developer get started at building all parts of an application: models, views, controllers and libraries, the one piece that’s lacking is advice on how to integrate with other people’s code. There a wealth of pre-written code out there, which though it may not be built to work with CodeIgniter, can save developers a ton of time as they build applications—if they know how to properly connect with third-party libraries from within the CodeIgniter framework. It can be a little bit tricky at first, so a primer in that area would be ideal.

Additionally, opening up the book with a bit of prior PHP experience is advised. Sometimes the examples don’t fully explain what’s going on in the code, so it could be a little complicated for a complete beginner.

Overall, though, I’m impressed with the direction this book goes. The angle is good, with a focus outside of the typical ‘build a blog in 20 minutes’ example.

Returning API Output to its Rightful Place

Most everyone knows I’m not a Rails guy, and that’s probably never going to change, much to many of my colleague’s dismay.

I do, however, appreciate many of the features of Rails. The one on which I’m going to focus today is its built-in ability to show output in various formats.

My beloved framework, CodeIgniter, doesn’t have this capability built in, and in my development travels, I’ve handled API output in a variety of ways. All of them work just fine, but they really didn’t conform to the MVC architecture. API output, at least how I see it, should be sent to the browser through a view, just like any other sort of output.

A week or so ago, I created a helper that handled all the necessary API output stuff, including converting to JSON or XML. It worked just fine, but I found myself having to refer to the syntax a lot, every time I wanted to use it. It was just too cumbersome. And at about the same time, I began thinking how nice it’d be to use the familiar $this->load->view(); view loader method for APIs, too.

So, that’s just what I did. I took some of the logic from the helper and piled it into a one-size-fits-all view for APIs. It’s a little odd at first, when you look it it, since there’s a whole lot of code, which you don’t usually find in a view file, but, considering you never have to touch any of it directly, it works quite nicely.

I’ll post the code later on, but I just share my thoughts about this method of handling API output from CodeIgniter.

What I’ve Been Up to Lately

I just thought I’d give a brief update about things I’ve been doing and working on lately.

In no particular order, except that which they came out of my mind and into my fingers:

  • Switched my blog over to use Disqus for comments. I’ve seen it used elsewhere, and I like the idea of integrating my blog with Twitter and Facebook. I don’t really get a lot of comments here anyway, so we’ll see how it goes. I did have one issue with the WordPress plugin for Disqus, thought. The import function, which is supposed to copy all your existing WordPress comments to Disqus did not work. If anyone has any ideas on what could be wrong, let me know. Everything looked good and it says it did it, they just never show up.
  • Started playing with MongoDB. I’ve been hearing a lot about the NoSQL style databases, as we all have, and I’ve been curious about using them. MongoDB had fairly good documentation and looked like a pretty simple PHP implementation, so I choose it over some of the other options. I ended up using the 10gen packages for Ubuntu/Debian to install Mongo on my servers. You might note that the packages only support Ubuntu 9.04+.
  • In the process of installing Mongo, I managed to bork my one server pretty bad, so I restored from a backup and created a new one for testing. After getting a testing server up I decided to take a big giant step and install Ruby on Rails to get started experimenting with it a bit more than I have previously. Until now, I’ve avoided it, as I don’t enjoy the copious use of command-line tools that are involved in Rails development and deployment. I’ve been known to call Rails proponent ‘commies,’ because of its highly-automated scripts. Luckily, in the last few months, as I’ve gotten used to running my own Ubuntu servers, I’ve become a lot more comfortable with the command line. So, I felt like it was time to give it another try. I installed Passenger in Apache, so it’s all set to go.
  • After getting Mongo and Rails setup on a new cloudserver, I decided to make sure I could do it all over again. Being able to replicate my setup is pretty key to me, so I downloaded a copy of VirtualBox and dove into the world of virtualization, as well. So far so good; I now have a very similar Ubuntu 9.10 server running locally within VirtualBox. It seems like Virtualization has come a long way since I last used Parallels on my Mac. I always found that the virtual machine would bog down the rest of the system so much that it made the system fairly unusable. It doesn’t seem to be the case with the latest generation of virtualization software. It really makes me wonder about setting up a virtual cluster of servers somewhere… cuz you know, I need that much power.
  • Client work out the ears. I incorporated my own development firm, Conflux Group, Inc., in January, and since then I’ve been quite busy doing client work. I feel like I’m off to a good start, having plenty of work to keep me busy every week, but I still would like to expand my client base, so as not to put all my eggs in one basket.
  • New lens for my SLR. I’ve been thinking about it for a while, and I finally went ahead and got myself a new lens for my Olympus E-500 DSLR. It’s a bit of an odd camera, not too common, so lenses are a bit hard to come by. I settled on a Sigma 50mm f/1.4 lens. The results are beautiful, even with my lack of photography ninja skills.

That’s most everything for now. I hope to have more to say about my experiences with MongoDB and Ruby on Rails as I dig in further.

One final note. If you’re a CodeIgniter or ExpressionEngine person, you should definitely consider coming to EECI2010 in San Francisco this May. I’ll be there, along with my posse of nerdy counterparts hailing from all over. It should be a great time, and I’m really looking forward to it.

A vCard Library

Today I was searching around for a good vCard library to use for an application I’m currently building.

I came across a library by Carlos Alcala in the CodeIgniter Wiki. I wasn’t completely satisfied with the library as it was written, so I took the liberty of rewriting it to meet my own personal taste.

You can take it or leave it, but I’m quite happy with the result. I’m not going to go over it here in detail, as the comments are fairly self-explanatory, and a sample controller file is included, demonstrating various usage of the library.

Download CodeIgniter vCard Library .zip file