/ Coding

From CodeIgniter to Laravel - part 1

I don’t give a shit what the rockstar developers tell you, CodeIgniter is a great MVC framework for building all kinds of websites. But there comes a time when it makes sense to switch, here’s why.

First, this is going to be a series of posts about what it’s like switching form CodeIgniter to Laravel. The series is not meant to be a complete tutorial for Laravel.

While I will pick out some of the key features available with Laravel, I won’t be doing a feature-by-feature comparison. The series is more about build considerations.

Which brings me to this: if you’ve been happily using CodeIgniter and are feeling the pressure to change, think first. There’s no reason to switch unless the projects you are working on justify it. I’ll talk about three key features in a sec that might drive the decision.

Right, ready?

Three key features

Using CodeIgniter to build a website these days is a bit like having a second doughnut. You know you shouldn’t, you know their are tasty alternatives, but it just feels good.

Yeah. But then there’s Blade. Oh, and routing. Don’t forget migrations...

Laravel’s templating engine (Blade) is the best out there in the PHP world. CodeIgniter has nothing close to it. Blade makes multiple layouts, partials and code integration easy. It’s like having that second doughnut and realising that it’s equal to two of your five a day.

Blade is so good that it makes switching to Laravel worth it on its own.

Next, routing. CodeIgniter routing is basic. You can bend it to do all sorts, but it’s a hack to say the least. I’ve worked on multi-tenanted builds with CodeIgniter. The routing ended up being beyond mental.

Laravel routing by contrast, makes life easy. Hell, you don’t even have to use a controller action if you want to load a static page.

I mentioned migrations. The current CodeIgniter implementation is incomplete. Laravel migrations give you complete control. I mean complete control. You can roll ‘em back, add to them and make new ones with a few simple commands.

Build considerations

I used to think boshing out a quick prototype was best done with CodeIgniter. Download it, throw it in a directory in your local web dev setup and away you go.

Yeah...

Laravel new brilliantidea

That kinda wins, though.

Use CodeIgniter if:

  • You have to deploy to a crappy, old server that might not support the latest PHP version
  • You have to deploy to a shared hosting plan. You can deploy Laravel builds in that situation, but it’s not ideal.

Otherwise, use Laravel.

A slight diversion for a moment. I call Laravel: “Larry”. Because I don’t like the name, it’s weird. Taylor used a great name for the templating engine (Blade) but Laravel? Nah.

Anyway....

The learning curve

It’s fair to say that Laravel does have a steeper learning curve than CodeIgniter. It’s structure seems all over the place at first and views aren’t even where you’d think.

Not only that, but to get it running takes a bit of effort too. I’m going to be bold and say: don’t use Homestead (oh, and don’t use Windows either).

Many devs get on perfectly well with Homestead. I didn’t. It was buggy and awkward when compared with Valet.

So, there’s my first piece of real advice: set up Valet for local development. You can run CodeIgniter and Wordpress projects through it too.

In terms of getting started, CodeIgniter aficionados are used to good documentation. Laravel has excellent documentation too. Always start their first when you are trying to figure something out.

Up and running

In this series, I’m going to assume you are using a Mac. Or maybe Ubuntu Linux.

I’m also going to assume you’ve opted for Valet for local development and you’ve been using CodeIgniter for a while.

Ok then, I’ll see you next time, where I’ll be talking about making a simple prototype site.