Simple-REST – Lightweight PHP REST Library
Web 2.0 has brought more and more social and syndication medium to the Internet world. Nowadays, every other web application is exposing web services for exposing their content and functionality. To enable web services, we rely on the protocols such as REST, SOAP, XMLRPC etc. Among these, REST is fast becoming a de-facto standard for the webservices implementation. Number of REST libraries are available in different programming languages to enable quickly the RESTfulness in your application. For PHP, you can find Zend_Rest, RECESS, FRAPI, CodeIgniter and so on. Although they are good, however I didn’t find that they are lightweight and simple. Therefore, I had wrote a REST library in PHP which is dead simple to use and install. I was using this for the past 2 years in different applications which now I decided to open source so that others can also make use of it.
Simple-REST is a very lightweight PHP REST library which allows you to quickly enable REST api’s in your application. It supports multiple response types – JSON, XML, Querystring. The Simple-REST library is released under Apache 2.0 licence. The only requirement for this library is the Apache mod_rewrite support.
For more details about this, you can fork or download it from Github – https://github.com/deepeshmalviya/simple-rest

15 responses to "Simple-REST – Lightweight PHP REST Library"
21:35 on August 1st, 2011
Hi, i just found your Simple-REST – Lightweight PHP REST Library a moment ago an i’m considering using it for a live project. thanks for the library though i have few questions:
It seem like your library is more of a REST Server than a REST client, am i wrong?
21:50 on August 1st, 2011
@cazuka, yes it is a REST server. REST clients are generally straight forward (curl based..).
15:59 on August 2nd, 2011
Does it have authentication so that 3rd parties trying to use my Rest API will be authenticated. So that only registered 3rd parties are allowed to use my api
19:27 on August 2nd, 2011
@cazuka, no, It does not have authentication. Authentication varies by application to application so you can implement it on the Controller side or the underlying application business logic and in case of failure, $this->responseStatus should be 401. Other way could be implementing an AuthController extending RestController and then rest of the controller extends your AuthController.
20:39 on August 10th, 2011
Hello,
thanks for this library. It works wonderfully. I have one question:
how can i integrate ssl or https in the rest server?
22:47 on August 10th, 2011
@sks, Thanks for the appreciation. You can just upload the rest library to the document root of your https site and it will work seamlessly like http.
20:51 on August 11th, 2011
It dosen’t work. I have the error “URL was not found on this server. Apache/2.2.17 (Fedora) Server at prestashop Port 443″. Do you have an idea to resolve this problem in the .htaccess file located in the rest library? Thanks
23:40 on August 11th, 2011
@sks, can you elaborate on what is the document root for your https site and where you uploaded the rest library? No need to provide actual details, it can be hypothetical.
19:47 on September 3rd, 2011
Hi Deepesh,
I have created similar framework that maps PHP Methods as RESTful API
called Luracast Restler (http://luracast.com/products/restler) It is also an open source project hosted in GitHub (https://github.com/Luracast/Restler)
Looking forward for your contributions to Restler
Regards,
Arul
14:48 on January 4th, 2012
Hello Deepesh,
Thanks to Share the Library..
I have one question :
I am returning the values as xml output. How to define a cdata ?
Thanks in advance,
svnindia
19:33 on May 18th, 2012
This Framework is awesome !!!
Just drop your controllers and works like a charm !!!
Thanks Deepesh ..
Just for Book-keeping, I used a separate file for RestController
3:31 on May 26th, 2012
Thanks, was looking for something very simple and this is exactly what I needed
Thanks !
18:15 on June 21st, 2012
Hey Deepesh,
Appreciate your efforts for sharing the code. Do you have any sample code for authenticating the users for accessing the API. Thanks in advance.
13:35 on November 28th, 2012
i want to apply character encoding for swedish character. can u please guide me