I have been looking into backbone.js and I can’t seem to figure out how to get it communicate with php in order to save the models data. It sends a request but how do I capture that request whether it be “Create”, “Update”, “Read”, “Delete” etc.
Thanks
Another option you may consider is to roll with a pre-packaged RESTful framework that has all the necessary functions built in to execute your Backbone server queries. My personal favorite is Josh Lockhart’s SlimPHP Framework.
Some simple sample code (once you have SlimPHP setup) used to take your Backbone calls look like this.
Here is a POST example that turns Backbone json into arrays.
Here is a PUT example using some parameters.
And here is a DELETE.
While this isn’t an exhaustive example of all the other things to consider, it should give you an idea of the kinds of open solutions already out there for you to use. I personally like Slim because it is so lightweight, simple, yet it has all the features you’d want in a RESTful server. Great for prototyping. Combine it with a DB abstraction layer and some other tools and you can make just about anything you want quicker.
You can see some other sample code along these lines here:
And here is a link to some other PHP based RESTful solutions: Framework List