Tiny REST framework in PHP

Posted: 2010-04-28
Category: PHP

resource index jsonI figured it is about time I start selling some of my work as the number of libraries and projects I have released open-source means I spent a silly amount of time answering support requests for free. As a step towards financial gain from coding I figured I'd give CodeCanyon a try, which so far is going fairly well.

I have created a really simple standalone RESTful framework that lets you use CodeIgniter style controllers without any of the weight of using a whole framework. It lets you handle GET, POST, PUT, DELETE requests with ease and return data in XML, JSON, HTML tables, Serialize, PHP syntax and CSV.

Sound familiar? Well it should! The codebase is based on my CodeIgniter REST_Controller which has been out for a long time now. It was a big part of my EECI2009 talk and was the basis of my recent NetTuts article "Working with RESTful Services in CodeIgniter".

Anyway, if you like my CodeIgniter REST_Controller but do not always want to have CodeIgniter on your REST server, give this a try. It is only 3 PHP files: index.php, config.php and REST.php class file then a .htaccess and your controllers. Very lightweight, very easy to use and incredibly useful for flexible RESTful APi's.

For only $7, what do you have to lose?

Buy Tiny REST Framework from CodeCanyon

Comments

Gravatar
Sid

2010-04-28

Good stuff. Will definitely give it a go if I need it sans CI.

Cheers

PS. My pants are loose, but I got nothing to lose :)

Gravatar

2010-04-30

Thanks for the heads up on the typ0, but now I have fixed it you just look like you are asking me for sex. :-p

Gravatar
Johnny

2010-06-07

You two should get a room. Codeigniter and anonymous, dirty, highway-rest-stop sex should not be combined. or.... should they?

Gravatar
Mike B

2011-01-30

In your examples of how to use Tiny REST, you show the following:
* /users - List of users (GET/XML)
* /users?format=json - List of users (GET/JSON)
* /users/profile?id=1&format=serialize - Serialized single user (GET/Serialize)

Does your code also allow for something like:
* /users/format/json - List of users (GET/JSON)
* /users/profile/format/serialize/1 - Serialized single user (GET/Serialize)
* /users/profile/1 - single user with a "default" method (serialize or JSON)

Thanks

Gravatar

2011-01-31

Only with htaccess rewrites. Really you should not be using format/serialize but should instead be sending HTTP Accept headers requesting the correct format.

Gravatar
Mike B

2011-02-01

Yep I understand that (using HTTP Accept headers rather than "format/serialize"). I was using your examples to ask if I could forgo the "?" and "&" separators and use path style separators instead.

Thanks

Gravatar
Mark

2012-08-13

Phil, has this been pulled from CodeCanyon deliberately? I can't find the framework, your link is 404ing now.

Posting comments after three months has been disabled.