php - Avoiding re-writing logic twice for server side and client side -


i writing piece of software allow user select different options product. prices vary depending on options selected. server using lamp stack. client using html5 , javascript. trying prevent re-writing validation , price calculations twice, once on server , once on client. have couple of options available @ point.

  1. do normal thing , re-write validation , price calculations twice
  2. do validation , calculations on server , use ajax update client (slow, want avoid.)
  3. implement secondary language supported both languages (lisp comes mind)
  4. write validation , calculation logic in javascript. use v8js library php
  5. use node.js

i'm trying avoid having many requirements project. if go route of node.js have install on seperate sub domain , purchase wildcard ssl certificate, or possibly certificate. i'd rather not throw on same domain , have weird proxy/request forwarding program decide if php or node.js should handle request.

some parts of php site need access data. using doctrine 2 orm. going route don't think using node.js best route go.

i'm leaning more towards option one, maybe can write code produce required java scriptcode. there other options i'm missing? suggestions? thanks.

will theoretic "complex" rewrites worth it? may not worth it.

but if -- solution reusing "backend"-like logic best. write in javascript , reuse in php -- it's ok.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -