4 ms·
Inline PHP-FPM Server Running on Node.js
- TamDenholm 16y agoOne other way might be to use phpjs.org, albeit a less complete version of it.
- davidcoallier 16y agoPHPJS emulates PHP but can't run PHP scripts :)
- ldng 16y agoNode.js neither. It merely passes the request to PHP-FPM. Neat hack but I fail to take it seriously. I don't see the benefit. Maybe I missed something.
- davidcoallier 16y agoIn this case Node.js acts as the webserver as Nginx or Apache would.
- joelhaasnoot 16y agoNode.js is low-level enough to do some protocol things fast enough PHP can't. I can imagine building a load balancer or proxy to PHP. Yes, it's probably not the best solution, but it could be done.
- arnorhs 16y agoAny possible benefits of doing this with node.js rather than just the normal nginx setup? Maybe if you're just running a simple node.js app but need to include one single-file php script? I guess that would be useful. Interesting concept. I like projects like this. It's also refreshing to see an article on HN mentioning PHP without it being something negative.
- lftl 16y agoMaybe this let you edit the PHP output in nodejs after receiving it back from PHP-FPM?
- arnorhs 16y agoGood point. That might be possible.
- KrisJordan 16y agoBeing able to pop into terminal, create a directory and a PHP file, then run node-php to get a test server running in this new setup is an efficient way to try code out. If the built-in PHP web server were standard this would be less useful.
- PaulHoule 16y agoUgh, the last thing we need is to turn open source people into Windows Weenies. Honestly, I like ASP.NET. If you're selective about what features you use, you're working with a language that's like Java, but a lot nicer, and a much better standard library. If you spent a few years coding web apps in say PHP or Ruby and you understand how real frameworks work and what's good about 'shared nothing', you'll do OK. However, like all Microsoft products, ASP.NET is full of traps. Things that you might think would be good because they came from a giant company, but that will just screw you up and waste your time. One of the most dangerous things that comes in Visual Studio is a phony web server that starts when you hit the F5 button when you start a web app. The phony web server is enough like IIS that you might think that your app will work on IIS when it's done, but in reality, it probably won't quite work -- and it can sometimes take days or weeks to fill the gap from "almost works" to "really works" I try to tell people that they should just install IIS (easy) and figure out how to make the app run on real IIS from the very beginning because somebody's going to have to do that work sooner or later.
- Refringe 16y agoHow does any of that relate to the link that was posted?
- robryan 16y agoHe is comparing running ASP.NET through the test server in Visual Studio rather than working out how to setup IIS to running something like this instead of working out nginx or apache.
- Refringe 16y agoYes, I know what he was talking about, just not how it relates to running a PHP-FPM server on Node.js. What was posted has absolutely nothing to do with ASP.NET and he's spouting off about how it's "full or traps" and how the development server that comes with the studio should be avoided. If you want to bash ASP.NET for no reason do it on your blog.
- davidcoallier 16y agoHere's a little video to show how it works :) http://www.screenr.com/aJ3 http://www.screenr.com/aJ3
- vlucas 16y agoFinally we have someone driving some innovation in the PHP space, and all people do is bitch and moan about it saying it won't work or it's not a good idea. That's the whole point of doing explorations... To find out if it's really viable or not. If this was related to Ruby/Rails, Python or Haskell, people would be cheering you on like you were in the Olympics. Keep pressing on, David - there are a lot of people in the PHP community who could benefit from something like this. I wish you and Orchestra the best of luck.
- kaylarose 16y agoI think something more like this [1]* built in server proposal would be nicer, with less dependencies. Yes, people always bitch about how easy it is to just set up Apache, but they fail to realize the departmentalization of apps is great for development. Currently in my dev environment I have a virtual host for every app/site/lib. It is rare that most PHP devs even do that. Far too often they just do FTP straight to the production server. This would curtail that. $ cd your/app $ php -s That said, I think the recent trend of lightweight servers for PHP is awesome. I think any additions to PHP that introduce real professional practices to the PHP community is a great thing. In the past few years we have seen the wider adoption of Unit tests, better frameworks, and somewhat better packaging. PHP devs always complain about how people rag on PHP, but it's because the professional programmers that actually know what they are doing don't spread their knowledge to amateur programmers - which leads to more crappy PHP code. Just like any other language embracing and evangelizing good standards will better the community as a whole. [1] http://news.ycombinator.com/item?id=2281724 http://news.ycombinator.com/item?id=2281724 (source link is down at the moment)
- auxbuss 16y agoVery interesting. One question: Could this in any way (at some time in the future, clearly not yet) provide a mechanism for PHP's lack of threads? I don't mean actual threads, but perhaps exploiting node.js's callback mechanism to sync the running of multiple simultaneous triggered PHP scripts.