How We Built Our REST API in One Week

Seven years ago I was a huge CodeIgniter fan. I built about five apps (two of which are now successful companies) using CodeIgniter and would attend events and speak evangelically about the framework. This month I switched to Laravel and I love it.

We needed to build a RESTful API for Uniteable, and build it pretty quickly. Our very talented front-end developer, Mitchell, was blasting his way through the task list and getting to the stage where he needed live JSON data to be stored and returned.

Having built APIs in CodeIgniter before, it was a temptation to stick to what I was familiar with. Also with the latest version (3.0.1 as of writing), a lot had changed and it was vastly improved. However, my good friend and developer, Rob George, had been talking about how great Laravel was. Version 5.1 (the latest as of writing) seemed especially impressive and was recommended to me many times.


The problem was that Laravel is a bit of a beast, to put it mildly. I had some experience with Symfony years ago and I was very put off by it, as it seemed very complicated and bloated. I tend to prefer lean frameworks with a very small footprint, which was why CodeIgniter was so compelling.

After I did some reading on Laravel, I was very much in admiration of Taylor Otwell for creating something that took the best bits of Symfony and simplified it. Their documentation is thorough and the large community is great, because there are many Stack Overflow questions and answers.

However, I was still nervous because it felt like a big jump for me.

Despite my reservations, I took the plunge and paid for a tutorial on Udemy which taught how to build a REST API in a few simple steps. The tutorial was amazing and found that, once I started getting the hang of it, Laravel was a lot simpler than I thought.

Laravel is very powerful, yet it can do so many things with just a few lines of code. I found that after completing the tutorial I had built the early stages of our Uniteable API in just a day or two. We had the routing, the CRUD methods (for simply creating, reading, updating and deleting streams and messages), and basic authentication.

...I had built the early stages of our Uniteable API in just a day or two.

By the end of the week I had implemented JWT authentication, and got really good at twiddling my thumbs (just kidding!). I still have a lot to do on the API, but it’s fully functional and gives Mitchell what he needs.

I’m very impressed with how easy Laravel is to learn, and how it allows for super clean code in the Controller (which is something my previous apps certainly don’t have). As an example, a request to output all the messages is just two lines of code - one line to get the messages and another to output the messages in JSON format.


Laravel is REST ready, straight out of the box. It reads JSON and returns JSON without messing around. Also, should you need to pull in additional libraries to do things that Laravel doesn't (e.g. formatting output with Fractal, or Debugging with DebugBar, or JWT authentication), you simply add a line of code into your composer.json file.

There are plenty of other great things about Laravel, such as Artisan; a command line tool that allows you to create controllers, models and seed your database with a few words in your command line (e.g. “artisan make:model User”). I won't go into detail on that now, but just know that it's wonderful.

All of this has saved many hours creating boilerplate code and more importantly, has enabled me to make a powerful, secure, fast and robust backend for an app that’s already beginning to look amazing (by the way have you signed up for the BETA yet?).

Thank you, Laravel!

Cover photo by Mike Rohde