Backbone和PHP模型代码重复

So I have decided to take a project I have been working on, and project management system, and convert it from a standard multi-paged application to a single-page application. In the process I have looked at a number of javascript MV*ish frameworks (ember, knockout, backbone, etc...) and have decided to go with backbone.js as it seems the most flexible solution and that I already use underscore.js for both its utilities and template system.

The one biggest concern I have with doing this is the potential code duplication I am going to have for model and business/domain logic in both my PHP models and in my backbone models.

This is just a technical cost I have pay when going with an architecture like this or are there some things I can do to lessen this concern?

If you are using different languages in server and in client I think there is not possibility to avoid this partial logic duplication you are concern on.

If you definitely want to use same code in server and client you have to move all of it to the only common language: JavaScript.

There are multiple JS frameworks those integrate very transparently the development between server and client: derby, meteor, ...

You may want to take a look at a previous question I answered involving Node.js:

Reusing backbone views/routes on the server when using Backbone.js pushstate for seo/bookmarking

What I'm currently doing right now is using Davis.js + Mustache + Java Spring MVC backened (based on my original question: Single page Web App in Java framework or examples?).

If the browser does not support Pushstate then I have the server do the entire rendering of the page using a Java version of Mustache (ie standard Web 1.0). If the browser does support Pushstate then the browser will make an AJAX request for a JSON version of the model. The model is then rendered client side use icanhz (ie javascript mustache).

This works fairly well if a large part of your logic is getting a model an then rendering it based on specific URL. That is your business logic is "based on some URL I'm going to render this". This is how most of the sites on the web work (including this one which is still rather web 1.0). Obviously this would not work for say something like real time chat or HTML5 game.

A python version of this design is mentioned here: http://duganchen.ca/single-page-web-app-architecture-done-right/

I'm sure someone has done a PHP version.