最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to use Backbone.js with the Symfony framework and or Apache Thrift - Stack Overflow

programmeradmin1浏览0评论

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.

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.

Share Improve this question edited Sep 20, 2012 at 19:24 j0k 22.8k28 gold badges81 silver badges90 bronze badges asked Apr 25, 2012 at 14:13 underscore666underscore666 1,7395 gold badges24 silver badges38 bronze badges 1
  • 1 well... you'd make a rest service in symfony2 and then access it through backbone... – tkone Commented Apr 26, 2012 at 2:02
Add a ment  | 

2 Answers 2

Reset to default 5

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

Check this bundle https://github./gigo6000/DevtimeRafflerBundle it's a small simple app that includes some basic REST actions. This was created with https://github./gigo6000/DevtimeBackboneBundle

发布评论

评论列表(0)

  1. 暂无评论