how to use Backbone.js with the Symfony framework and or Apache Thrift

backbone.js, javascript, symfony, thrift

Solution

By default, Backbone.js and its sync method can work with REST APIs without any modification. So if you can create a web service with Symfony2 that can handle GET/POST/PUT/DELETE and return JSON, you should be good to go.

I'm not terribly familiar with Symfony, but for a basic REST API, you'll need to define your URL routes (e.g. "www.yourdomain.com/api/items"), and then create methods to perform actions based on those routes (e.g. return records in JSON encoded format).

Here's a quick tutorial on creating a REST API with Symfony2: Symfony2 REST

Also, check out Wine Cellar tutorial on the Backbone tutorial page. It uses PHP Slim framework, but the backbone.js concepts will be exactly the same, because as long as you are using a basic REST API, backbone is back-end agnostic.

Problem

I recently installed a web app which use `Symfony2` framework and `Apache Thrift`. Now I would like to make backbone usable in `Symfony2` framework. My question is about `Backbone.sync`. How can I override/use `Backbone.sync` in order to get data from the server in a web app using `Symfony2` framework and/or `Apache Thrift` ? Are there some tutorials on the web for do it? I just found this one Symfony + Backbone.js for highly dynamic apps, but it doesn't say nothing about how to get data from the server.

Original source