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.
- do normal thing , re-write validation , price calculations twice
- do validation , calculations on server , use ajax update client (slow, want avoid.)
- implement secondary language supported both languages (lisp comes mind)
- write validation , calculation logic in javascript. use v8js library php
- 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
Post a Comment