简体   繁体   中英

How do I set up server side end points for a backbone.js app using sinatra and codeigniter?

I want to create single page applications using backbone.js and want to deliver these apps to my client using php and ruby.

I like both Sinatra and codeigniter. How would I go about setting up server side endpoints for my application? Right now I am developing a cloud computing billing calculator.

Where do I create models and collections? On the client and server side?

Backbone is a client-side JavaScript solution offering models, views and collections (of models) that help you manage your data and views on the client-side. Backbone, by default, can populate its client-side models with data from a server using REST APIs.

You can build your server-side models however you want, but (by default) they need to be accessed through a simple REST API like this using the model functions, sync(), fetch() and save():

  • create → POST /collection
  • read → GET /collection[/id]
  • update → PUT /collection/id
  • delete → DELETE /collection/id

More information can be found here:

http://documentcloud.github.com/backbone/#Sync

Here's an overview of how to create a REST API with code igniter:

http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/

Here an overview of how to create a REST API with symfony:

http://di-side.com/di-side/services/web-solutions/rest-webservice-symfony/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM