简体   繁体   English

如何使用sinatra和codeigniter来为ribs.js应用设置服务器端端点?

[英]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. 我想使用lobb.js创建单页应用程序,并希望使用php和ruby将这些应用程序交付给我的客户端。

I like both Sinatra and codeigniter. 我既喜欢Sinatra和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是一种客户端JavaScript解决方案,提供了模型,视图和(模型的)集合,可帮助您在客户端上管理数据和视图。 Backbone, by default, can populate its client-side models with data from a server using REST APIs. 默认情况下,Backbone可以使用来自REST API的服务器数据填充其客户端模型。

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(): 您可以根据需要构建服务器端模型,但是(默认情况下)需要使用模型函数sync(),fetch()和save()通过这样的简单REST API访问它们:

  • create → POST /collection 创建→POST /收集
  • read → GET /collection[/id] 阅读→GET / collection [/ id]
  • update → PUT /collection/id 更新→PUT / collection / id
  • delete → DELETE /collection/id 删除→删除/ collection / id

More information can be found here: 更多信息可以在这里找到:

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

Here's an overview of how to create a REST API with code igniter: 以下是有关如何使用代码点火器创建REST API的概述:

http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/ 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: 这里概述了如何使用symfony创建REST API:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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