

Inline PHP-FPM Server Running on Node.js - davidcoallier
https://github.com/davidcoallier/node-php

======
vlucas
Finally 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
I 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> (source link is down at the
moment)

------
arnorhs
Any 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.

~~~
KrisJordan
Being 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.

~~~
arnorhs
But you'd probably be quicker to get nginx up and running - so I was wondering
if there were any benefits _beyond_ a nginx/php-fpm setup

------
auxbuss
Very 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.

------
TamDenholm
One other way might be to use phpjs.org, albeit a less complete version of it.

~~~
davidcoallier
PHPJS emulates PHP but can't run PHP scripts :)

~~~
ldng
Node.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.

~~~
joelhaasnoot
Node.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.

------
davidcoallier
Here's a little video to show how it works :) <http://www.screenr.com/aJ3>

------
PaulHoule
Ugh, 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
How does _any of that_ relate to the link that was posted?

~~~
robryan
He 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
Yes, 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.

~~~
PaulHoule
I'm saying that a phoney PHP web server for Unix is just as bad as phoney
ASP.NET server on Windows.

