
Exploring an AST-Based Template Engine in PHP — Thoughts?
I’ve been exploring an idea and would really like to hear different perspectives on it. What if a PHP template engine (like Blade) moved from being string-based to an AST-driven pipeline (lexer → parser → AST), so it actually understands the structure of the template instead of just compiling it? The thought is that this could produce a tree representation of the view (some kind of server-side VDOM). With that, it might be possible to clearly separate static and dynamic parts based on AST analysis. In theory, instead of re-rendering the full HTML on every request, the server could work at a node level: identify which parts are dynamic track them as nodes in a tree and update only those parts when data changes Something conceptually similar to how virtual DOM works in frameworks like Vue, but driven from the server side. For example: dynamic variables could be detected at compile time certain values could be marked as “live” the browser could request only those live parts (e.g. via smal
Continue reading on Dev.to
Opens in a new tab



