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.

Introducing API View

In my last post, I talked about my thoughts on moving API output in CodeIgniter to the View. Well, here’s the code for it. It’s fairly simple.

A couple little notes:

  • Using this view requires the PEAR XML Serializer library. Assuming your PEAR libraries are in your path settings, the view should work. You may need to adjust the path to the libary, though, on line 56.
  • This code isn’t meant to be pretty. In most cases, your views get laid out with as little PHP code as possible, making it easy to style them. This is a different kind of view. It’s only purpose is to make API output use the same syntax as loading any other view. Because of this, this view does lots of nasty things that you should NEVER do in a normal view. This is your disclaimer. I created this for my own purposes to work the way I wanted it to, and if you have objections, it’s certainly understandable, but I don’t really care. :P

Anyway, without further ado, if I haven’t scared you away, why don’t you give it a try?

Download the API View