Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

  1. 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 ?

  2. 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.

like image 236
underscore666 Avatar asked Apr 25 '12 14:04

underscore666


1 Answers

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.

like image 169
eterps Avatar answered Oct 10 '22 02:10

eterps