» CakePHP REST Plugin presentation
At our company we have a lot of uses for a solid API. We can use it to distribute config files, have servers report in, let customers edit DNS records using their own interface, etc.
Now that I'm converting all of our legacy code to a big CakePHP application, the API needed a revisit as well. I chose to use REST as a standard, read about everything related to Cake & REST, and started hacking on a reusable plugin. The idea is that you can drop it in any application and unlock existing functionality to REST with minimal changes to your code.
It is still a work in progress, but as the first Dutch CakePHP event was held yesterday and I was asked to present something I thought this particular plugin might be of interest to the community. Here are the slides:
I would love some feedback to help it make better. My todos can be found in the slides as well, to give you an idea where I'm heading with this.
More info on the Dutch CakePHP event
- @jsentel's writeup on the talks
- Singel 146's followup (the location in Amsterdam)
- @charli3's initial post
- #cakephpnl on twitter
- LinkedIn group: CakePHP NL
Stay up to date
You can track my blog
articles and
comments. You may also find my
bookmarks interesting. Or
Follow me on Twitter
Like this Article?
|
Your money is no good here, but you can boost morale by spreading the word! : ) |
RelatedArticles like this one» Prepare for PHP 5.3 |
tags: cakephp, programming, rest, php, api
category: Programming - PHP - CakePHP
read: 4,253 times






tagcloud
#12. Paul Winkeler on 16 August 2010
#11. Kevin on 29 June 2010
Furthermore, you may find the clien-side of this API interesting that I developed for my company:
http://github.com/true/true-api
#10. steve on 22 June 2010
[0] => Content-Disposition: attachment; filename="DSC01264.JPG"
[1] => Content-Type: application/octet-stream
[2] => Content-Length: 64250
... [more] [3] => Authorization: OAuth realm="", oauth_requester_id="720", oauth_signature_method="HMAC-SHA1", oauth_signature="Rom3hREK8p2PzMBXdzIJb3hy%2FF0%3D", oauth_nonce="4c210a01d83d9", oauth_timestamp="1277233665", oauth_token="", oauth_consumer_key="1385adb7be6ade0a0bf7d5493fd0722404c1795eb", oauth_version="1.0", xoauth_body_signature="8ap46NO3buRxIbzAtFc5OFa6FNY%3D"
thanks,
Steve
#9. steve on 11 June 2010
I am building a REST API now, and I could use all the advice I could get.
Thanks!
Steve
#8. Kevin on 10 June 2010
as (kind of) explained on: http://github.com/kvz/cakephp-rest-plugin
#7. steve on 08 June 2010
Thank you very much for this plugin! I am a bit confused about the authentication. Does this plugin actually handle the Amazon-style authentication and return the appropriate HTTP response codes? Or, does it simply parse out the Amazon-style Header:
`Authorization: TRUEREST username=john&password=xxx&apikey=247b5a2f72df375279573f2746686daa`
... [more] into an array that can then be used effectively with some other security component?
Thanks,
Steve
#6. Kevin on 29 April 2010
Your index is fine.
If in that controller you specify:
It should show you the contents of products under 'myProducts' in json format, when you browse to /index.json
#5. gkibria on 24 April 2010
And Here is my index()
my cake_core is 1.25 thanks
#4. Kevin on 24 April 2010
No the trick is you
like you would normally with your index()
Only the restcomponent can take the viewVars you specify, maybe even convert them into another (more rest-consistent) format, and them json_encode them.
XML serialization is being worked on.
#3. gkibria on 24 April 2010
Thanks for your plugin. I have a products controller with index action working fine. When I added Rest.Rest component in my products controller I got "Error: The requested address '/products' was not found on this server." for /products
And /products.xml give me" XML Parsing Error: no element found"
... [more]
When I disable Rest.Rest component, /products are working fine. Can you tell me what's wrong?
Another thing, Do I have to place any additional code in index() action?
Many Thanks
#2. Kevin on 14 March 2010
/posts/view/1
you could add the Rest component to your PostsController and then you could do
/posts/view/1.json
... [more]
to get the same data but in json format and with additional features like authentication
#1. Tamas Jozsa on 12 March 2010
This plug-in is exactly what I'm searching for. Will try it out today and when I have time I will return to give a feedback.
One thing I do not understand so far is, how to call this from a browser. Is it like:
... [more]
www.hostname.com/rest/<modelname>s ???
And how to select whether to output to JSON or XML. As I see in the code XML is there in many places.
Thanks,
Regards,
Tamas