4 ms·
I use the following architecture: Browser -> POST -> Database -> XML -> PHP + XSLT => HTML Prevents HTML from being mixed with PHP. PHP becomes the "contr
by thangalin 14y ago
I use the following architecture:
Browser -> POST -> Database -> XML -> PHP + XSLT => HTML
Prevents HTML from being mixed with PHP. PHP becomes the "controller" in the MVC world. This makes the application easy to migrate to another language.
- astrodust 14y agoXSLT plus PHP? Are you a masochist?
- klibertp 14y agoWhy do you think so? This makes perfect sense to me - imperative language wraps purely functional one, and sits on top of declarative, relational language(s)[1] for data storage and manipulation. The GP is using a very well thought out configuration; this is using the right tool for the job incarnate. If I wasn't lacking in SQL department I would probably do exactly the same (probably replacing PHP with something strongly and maybe statically typed). [1] SQL and XML seems a bit redundant, but I don't know what they are used for exactly. Also I lumped both SQL and XML together as "relational" because of XQuery, but I admit that I don't know much about the latter and this may be not accurate.
- thangalin 14y agoLong ago I learned that system source code is not as important as data. You can always hire hot-shot software developers to (partially machine-)translate the system into the langue du jour. Using XML allows means the data associated with every "page" in the system automatically doubles as a service (SaaS). XSLT allows those those services to be translated into JSON, ASCII, PDF (via LaTeX), XML, or the format du jour. With this architecture, the amount of time to publish a new export format for every "page" in the system is reduced to the time it takes to write a new XSL template: hours to a few days. All pages can reuse the same code to render themselves: $data = get_xml( $id ); $xml = get_xml_dom( $data ); $xsl = get_xsl_dom( $stylesheet ); $proc = get_xslt_processor( $id, xsl ); echo $proc->transformToXML( $xml ); This cleanly separates business logic and the data model from presentation, plus much more. Perhaps it is masochism, though. ;-)
- astrodust 14y agoI'd prefer to pick a language for the job that can handle manipulating the data as well as emitting it in the correct format. Having to duct-tape XSLT on top of PHP just because PHP can't cut it is rather perverse. The only thing I can think of that's worse than "programming" in XSLT is ColdFusion.
- thangalin 14y agoWhat language can make every page output XML, PDF, JSON, or ASCII, without changing the business logic, data model, or spending more than a few hours developing each new format?