0

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?

2
  • Sorry @Amit but I feel this question very generic and imposible to offer a proper and concrete answer. Commented Mar 13, 2012 at 15:22
  • It is generic because I am trying to grasp the situation and not solve a specific problem yet. Commented Mar 13, 2012 at 16:47

1 Answer 1

4

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/

Sign up to request clarification or add additional context in comments.

2 Comments

so do I also have to mirror my client models on the server side?
@AmitErandole, essentially, yes. Currently, without using some crazy hacks with node.js you can't just use your backbone models on the server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.