Question

Hey so I have been trying to create a RESTful API using codeigniter 2.1.4.

I am an intermediate php programmer and originally debated created the API from scratch.
However, after some research, looking through old questions here and on google I picked up a couple tutorials and third party libraries.
One of the easiest to follow I found at nettuts+.
This looked like a great solution as it used the philsturgeon / codeigniter-restserver third party libraries but the tutorial its self was written in 2010.

Upon further inspection I realized that the majority of the tutorials using these libraries were at least 2-3 years old. Will this cuase any issues?
Can I still follow the tutorial at nettuts+ Or should I just write my own RESTful API?

Was it helpful?

Solution

It looks like CodeIgniter 2.0 was released in January 2011, nearly a year afterwards, so it may not work. However, CodeIgniter has always been quite strong on backward compatibility, so you may be able to use it without issues.

That said, CodeIgniter is IMHO not the best choice for building a REST API (I've done it myself and I wouldn't recommend it), and it is falling further and further behind some of the more modern PHP frameworks. If it's at all possible or practical to switch at this stage I would use a different framework that's better suited to building API's - if you wanted a full-stack framework that's easy to learn if you know CodeIgniter, Laravel is a good choice, or for something more lightweight, try Slim.

EDIT: Based on the requirements you mentioned in your comment, I would be happy to recommend Laravel over Slim for this use case.

Most server-side frameworks can be sorted into two types:

  • MVC frameworks (eg Rails, Django, CodeIgniter)
  • REST microframeworks (eg Sinatra, Slim, Flask, Express)

Laravel is the first framework I've seen that effectively bridges the gap between these two types. It's also a relatively easy switch if you already have experience with CodeIgniter, has a wonderful ORM, makes unit testing easy, and is built on top of Composer, making it easy to keep it up to date.

Tutorial wise, I can point you at this list of NetTuts tutorials (as long as you stick with ones that cover Laravel 4 you should be fine), and the official documentation, which is extremely good.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top