I have worked many years with PHP, today I work a lot with Python, Nodejs and Nginx. I have a slightly different point of view from those presented so far.
Node replaces Apache and I have to choose between one and the other?
You can use Node to be the server too, but it is not a good practice, it is possible to integrate Node to work with other servers, including Apache.
Does Node replace php? For example when by Node itself we have the Mysql connection?
Node can replace PHP yes, can connect with Mysql and other databases, such as PHP, depends on the purpose of your application and the strategy you want to adopt Node can be a more appropriate solution than PHP.
Node integration with Cakephp or another Rails-like framework is not possible?
You will not be able to write a file with PHP and Javascript and process both at the same time, but integrate them is possible yes, both PHP make requests to the Node server and the other way around. It is also possible with Rails or Python. Today we use in the company where I work a middleware server made in Python with Django integrated with distributed Node servers that make the communication part in asynchronous websocket.
If I have an application ready and want to integrate it into Node, I have to rewrite it?
It depends on what you want to integrate, but you’ll probably need changes to the integration points to work with the new dependencies.
Does Node depend on Nginx? If not, using 2 at the same time is a good output?
It is not dependent, but Nginx is a great server to work with Node, either to be part of cache or even to work with multiple upstream nodes, allowing load balancing on your servers.
One of the things you can do to integrate your systems is to have the Nginx server giving external access and mapping the paths that will fall into the nodejs and the ones that will fall into your apache that provides PHP (if you use Apache features integrated into your PHP, otherwise you can use Nginx to directly access your PHP as well).
So in case you monitor a COUNT
In real time, one of the interesting applications would be a nodejs websocket server, where its users could be connected and traffic data in real time. On the server side your PHP could warn your Node every time it does an insertion or deletion operation in the database so that Node replicates the value of COUNT
for your customers in real time.
All this operation is possible with PHP too, using Pushstream, but in the end it is so much more complicated, that it is worth adopting Node for such a solution. Even chat or games are cool to work with Node, because its purpose is to be treated as events in micro blocks and not as files processed as blocks and sent to the client equal PHP.
vc could indicate me a text or site where I can see an example of Count like the one you mentioned above?
– zwitterion
One of the ways I usually communicate between different languages is by using HTTP protocol (as it is quite simple and most support). Take a look at this site: http://resthooks.org/ the concept of Hooks applies to any communication layer whether between applications or client. But as for the client you have no way to turn the browser into an HTTP server waiting for a request, we use websocket or longpooling to request the server to the client when the hook on the server is triggered by another internal application. I have no opensource projects to demonstrate.
– Gabriel Gartz