2 ms·
Question: is there a Node.js package out there that lets me write in PHP style, without having to configure anything? I mean, I install node, I install the nod
by crazygringo 14y ago
Question: is there a Node.js package out there that lets me write in PHP style, without having to configure anything?
I mean, I install node, I install the node package, I start the server...
And then it just looks for an "index.node" file or something in a directory? URL's would map to node files? It would use some kind of templating syntax like <? ?> or whatever, but the point is, it would be as easy to use as PHP. (Each template could get the URL parameters, and read session variables, just like PHP.)
I've used Express, of course, but that's overkill for throwing together a little website. People love the PHP model of files. It's clearly not theoretically ideal, or particularly scalable, but it works and is easy.
Anything out there? Maybe I should throw it together myself...
- tikhonj 14y agoI don't think that model would fit all that well with node in particular. I'm not sure how would make a templating system like that play well with asynchronous calls. And using synchronous function everywhere won't work. (For example, I couldn't figure out how to read from STDIN synchronously, at all!) But even if you do decide to use the synchronous functions everywhere, having all your function names end in Sync would just add unnecessary confusion. So, while you idea certainly doesn't lack merit, it would make more sense for something other than node.
- crazygringo 14y agoHmm... you're quite right about that. At the minimum, there would have to be a per-page set of "code", which could contain async functions and result in a final callback, and then a separate per-page "template", which could not. And then that would kind of defeat the whole simplicity of the model, so you might as well use a proper framework. I guess that's why nobody's done it yet. :) Thanks!