DerekAllard.com

5 Things You May Not Know About CodeIgniter

Every time I start a new project with CodeIgniter I find myself tasked with something, often a small thing, that I’ve never “solved” before. I try to use these moments as opportunities to explore PHP and CodeIgniter a little bit deeper. Often times I surprise myself by learning something new, or surprise myself at having forgotten something relatively “basic”. Here are 5 things I’ve discovered or rediscovered in the last few years. If you’re a CI veteran, some of these will be old news to you, and some might be new. Maybe just like me you’ve forgotten about a handy trick. Regardless, they’ve become mainstays in my coding now, and I think they deserve a bit more recognition.

Keep reading to see the tips!

Modifying the default CodeIgniter Calendar template for fun and profit

A project I’m working on needs a monthly calendar. Naturally, I’m using CodeIgniter as the base of it. Here’s the default CI-based calendar:

default CI calendar

and here’s what I ended at (you can grab the files (CSS, config file, sample controller/view) below).

completed CodeIgniter monthly calendar

 

CodeIgniter Podcast: Episode #4

Yesterday I had a chance to sit down and do Episode#4 of the CodeIgniter Podcast with Phil Sturgeon and Kenny Meyers. It was a blast! I’ve known them (both in person and “virtually”) for several years, and have always enjoyed talking with them, but I wasn’t sure how it would translate to the “podcast” environment. Well, I think it translated great.

In my opinion, the best part of any free-flow discussion like a podcast is that you get the (reasonably) unfiltered thoughts of people who are just plain excited by what they do. Sure I wish I had a few less “um”s, but its a small price to pay to get to sit and chat with 2 of the smarter people in the community.

Phil did an amazing job - and heck, got it nicely edited and posted pretty much instantly; everything that guy does is fast and high quality (there’s a joke in there somewhere). Kenny Meyers is one of those guys who you just want to sit and talk with, his observation about the shift in server administration off the host and onto the developer still has me re-thinking how I approach things. Both of them were pretty merciful on making fun of my accent (what’s that a-boot anyhow).

I’m looking forward to doing it again, and to listening to future episodes from others.

If you have a half hour to kill, or can listen to talking and still get your work done (I’m not one of those people), then go have a listen.

Also, is it “eye-on” auth, or “eee-on” auth? These are the questions that keep me up at night!

New Challenges

Its with a sad heart that I write that I’m no longer part of the wonderful team at EllisLab.

When I joined the company in 2007, there were interesting challenges ahead. I got to be the only developer working full time to bring ExpressionEngine2 to market, and along the way got to envision, design and build some of the most interesting aspects of it - the configurable publish screen and the file manager, among others.

After ExpressionEngine2 made it to market, I had the opportunity to really dig into a new challenge, a new product, with no legacy and no expectations. It was a joy to bring MojoMotor to market. I spent my days dreaming about how it would work, how people would interact with it, and even fussed over little details like naming and icons. It was a lot of fun. MojoMotor has only been available for a short time now, but it is by all measures a success.

EllisLab has a strong core of products now, and a large, engaged community; and also a new management and a new direction. The type of challenges that excite me, that drive me, aren’t available anymore, and so while it appears sudden to some, my time at EllisLab has reached a natural conclusion.

I’m off now seeking new opportunities and the next challenge. I remain passionate about what I do, and what I’m good at - building fun, engaging software.

MojoMotor, and my EECI2010 review

EECI2010

Well, finally back and enjoying the afterglow of another amazing experience; EECI 2010. Aside from the great things that happened to me personally (I’ll get to those in a moment), it was 3 days of pure and utter awesomeness for the whole ExpressionEngine/CodeIgniter world. I’ll never get to hang out with a more awesome gang then the folks I meet through this world.

Rick Ellis said something unexpected and uniquely insightful during his keynote that really resonated with me. I don’t have the video in front of me for the exact words, but an accurate paraphrase would be “The community is where its at. In many ways, and all the important ones, the software is irrelevant.” As someone who has worked tirelessly over the last 3 or 4 years to build the software he’s referring to, I completely agree with this. The magic-sauce of EE and CI comes from the community of dedicated, passionate people around it. Its easy to forget that when we’re busy fighting deadlines and trying to fix IE bugs.

Now seems about as appropriate a time as any to extend my sincerest thanks to Robert Eerhart, Janneke van Amsterdam, and the entire Whoooz team. These folks put on one of the most professional, well organized, kick-ass experiences I’ve ever enjoyed. Every little detail was tended to, nothing was second rate - I wish I had Robert and Janneke organizing my day to day life… things would be so much better!

MojoMotor

The highlight of the trip for me was finally getting to talk about MojoMotor. Mojo is something that I’ve been working on since around Christmas last year, and its been nearly everything I’ve been up to professionally for 5 months. Anyone who’s watched my keynote at EECI2009 knows that I’m a “social coder”. I crave community; and I consider nerding-out with other people to be foundational to the way I work. Keeping Mojo under wraps for 5 months has been killing me! I want to share, I want to say “hey, check out this cool thing I’ve been doing”, but we decided very early on that we wanted Mojo to come as a total surprise. Now that its out there, I’m glad we did.

Response to the news of Mojo has been overwhelmingly positive. I’m really hopeful that people will end up loving it as much as they love CodeIgniter and ExpressionEngine. I few secret tidbits that not many people know about MojoMotor:

And of course, the journey is only just beginning for MojoMotor. The final round of beta testing with “real world” (ie: non-staff) testers is just getting underway, and after that we’re releasing. It’ll be in your hands quickly, I promise. The price has been set at $49.95. I’m looking forward to watching it mature and grow before our eyes.

CodeIgniter update, Jan 2010

There’s been some really neat activity on the CodeIgniter front recently. Great stuff.

Jamie Rumbelow has taken over as CodeIgniter Community Cheiftain, after an admirable job by the imminent Michael Wales. We’re lucky to have both as part of our community.

Rick Ellis has discovered Twitter (see him @rickellis) and is dropping all kinds of cool news about CI and EllisLab.

The CodeIgniter repository itself is getting a bit more love recently due to a few folks putting in their own time. Here’s how I spent my weekend (check out both the time (yup, 3am) and message of rev 1789 :)

Recent CI changelog activities

There’s a lot of exciting things ahead for the framework - its a great time to be involved!

EE 2 Week Straggler: The Return of Derek Allard! (Interview)

Last week my good friends over at EE_Insider focused on the imminent release of EE 2.0. If you haven’t read it yet, go read it now. They feature articles, interviews, and news, and always with a bit of humour (yes Kenny…. there’s a “u” in that word). They asked me for an interview, but after EECI2009 my wife and I took a few more days to tour around Holland… and l long story short… the interview only got finished right now :)

Go read EE 2 Week Straggler: The Return of Derek Allard! (Interview) for my thoughts on the future of CodeIgniter, the development of EE 2.0, and what it means to unite CodeIgniter and ExpressionEngine.

We had sent out a set of interview questions that we weren’t sure we would receive for ExpressionEngine 2 Week. Derek Allard, one of EllisLab’s developers, was on vacation. Since he’d been slaving away for years on EE 2, we gave him a free pass. But Derek is what the kids call a “trooper” and he came back to us this week with the answers! It turned out to be a really great interview, timely due to the discussion and popularity of CodeIgniter and EE, and we got permission from the ‘Lab to post it. So, EE denizens, it’s my pleasure to give you our interview with the great Derek Allard

Getting changes made to the CodeIgniter manual

CodeIgniter User Guide

The CodeIgniter manual is almost universally praised by the community*. I’m proud to say that we work very hard on our documentation at EllisLab - in fact as a coder, I’m forced to write the docs for anything I add or change. This means that they are pretty up to date, and reasonably complete.  Could things be better? Of course! There’s always room to improve anything, and our docs are no exception.

What I’d like to focus on here is how to go about improving the docs, and one approach to giving your suggestion the best possible chance of getting included.

 

Using JSON on servers without native support

If you’re building a distributed application one of the luxuries you lack is knowing exactly how the server that will be hosting your application is configured. One common obstacle I encounter is lack of JSON support (JSON is only natively available to PHP since version 5 version 5.2, and even then is not uniformly available on servers). Here’s how I code around this situation; firstly, if the server does support JSON, then I don’t want to mess with it, but if it lacks support for JSON, then we need to define the JSON functions so it can use them externally. There are 2 JSON functions that we want to re-create - json_decode(), and json_encode().

Often times these types of things are set using configuration variables (in CodeIgniter, the $config array), but a configuration variable in this case is not really desirable, as a server may get the ability afterwards, or the person implementing it may not set the variable correctly. What I do in order to ensure the system will guess correctly is simply use PHP’s native function_exists() function to determine if the server can handle JSON. If it cannot, then I re-implement all the functions using the PEAR Json_services file, which I implement as a CodeIgniter library.

// Not all servers will have json_decode() available but those that do should
// use it, and we'll fall back to another solution for those who don't. 
if ( ! function_exists('json_decode'))
{
    $this
->load->library('Services_json');

The library is available from the Pear repository and will work in any environment that CodeIgniter itself works in, simply drop it into your libraries folder.

function codeigniter_controller ()
{
    
if ( ! function_exists('json_decode'))
    
{
        $this
->load->library('Services_json');
    
}

    $json 
'{"a":1,"b":2,"c":3,"d":4,"e":5}';

    
$vars['json'json_decode($json);

    
$this->load->view('view'$vars);

I’ve used this technique successfully now across several CodeIgniter projects.

I’m speaking at the first ExpressionEngine & CodeIgniter Conference

I’m very pleased to announce I’ll be joining Leslie Camacho, Simon Collison, Veerle Pieters and a host of other brilliant minds at the the first ExpressionEngine & CodeIgniter Conference in Leiden (Netherlands) at the end of October.

2009 ExpressionEngine & CodeIgniter Conference

What doubly excites me about the entire conference (well… aside from the whole European vacation thing) is that they are specifically focusing on both of my favourite tools, not only EE or only CI, but both. The topics are balanced, the conference is very well organized so far… this will be a pleasure.

If you don’t already have plans, why not take a few extra days and make a vacation of it; and join us for several days of nerding out.