The next thing is to ask "do i need interativity" if you can say my server is the single point of truth ... you don't need node. Ofc you can use it but that's where it shines more than php
event loop is more common in node, you can use reactPHP, Libevent or you can actually use PCTL and write your own concurrency system as well as I am watching a special FPM client that stays alive.
Isomorphistic rendering. The bootstraping of react is different than with php -> for example: I render all my react sceleton parts on the server and the inital payload is rendered with volt. but I cannot pre-render the react component before delivering it has to be rendered on the client.
I think you can replace PHP entirely with Node but you don't have to. Sometimes node is more conveniant sometimes PHP is more conveniant.... or python or perl or go.
Node for me is a high performing interactive socket connection machine. which is good and cost efficient in what it does.
PHP is turing complete, it probably can do the same things, maybe not in the same way, which node does ... it just isn't designed that way.
For example: Having concurrent connection on a "native" server in PHP will keep the objects alive for all changing/incoming connections.
That mean you will have to really think processes through. Esp state and resources are interesting. To reduce memory consumption every passed object is a reference in PHP. This means you have statechange / sideffects everywhere .... unless you clone it.
new instances are costly (less with php7) if they happen often. So all of the sudden using "clone" instead of "new" get's more interessting -> it's just deep copying the state without calling the constructor.
So you break the reference behaviour, but you increase the memory consumption. That's complicated, if you do it right -> what do you keep ? what do you throw away ? That's not really the common PHP world. But it's the node world: a magic VM cleans up behind me, ofc you can screw things up.
Another thing is the MySQL connection of the PDO lib of PHP in combination with the Database timeout. The socket connection will be terminated from the database after 2 or 3 hours idling (depends on your socket) ... PHP does not know that gg guess what's happening ;D ....
Those are not the common PHP problems, Node handles that complexity more intuitive it's a integrated part of it, you find tons of solutions like futures and so on.
a PHP Future ? why ? every request 1 thread .... my request is the future...
And I am really good at PHP I've built concurrent systems, and generators coroutines using MQs to execute jobs and stream from a to b :). Still For a chat I will use nodejs because it's 2 libs and 20 lines of code. And other people will maintain those libs on regular basis :)
j
stuff ;)
I think you can replace PHP entirely with Node but you don't have to. Sometimes node is more conveniant sometimes PHP is more conveniant.... or python or perl or go.
Node for me is a high performing interactive socket connection machine. which is good and cost efficient in what it does.
PHP is turing complete, it probably can do the same things, maybe not in the same way, which node does ... it just isn't designed that way.
For example: Having concurrent connection on a "native" server in PHP will keep the objects alive for all changing/incoming connections.
That mean you will have to really think processes through. Esp state and resources are interesting. To reduce memory consumption every passed object is a reference in PHP. This means you have statechange / sideffects everywhere .... unless you clone it.
new instances are costly (less with php7) if they happen often. So all of the sudden using "clone" instead of "new" get's more interessting -> it's just deep copying the state without calling the constructor.
So you break the reference behaviour, but you increase the memory consumption. That's complicated, if you do it right -> what do you keep ? what do you throw away ? That's not really the common PHP world. But it's the node world: a magic VM cleans up behind me, ofc you can screw things up.
Another thing is the MySQL connection of the PDO lib of PHP in combination with the Database timeout. The socket connection will be terminated from the database after 2 or 3 hours idling (depends on your socket) ... PHP does not know that gg guess what's happening ;D ....
Those are not the common PHP problems, Node handles that complexity more intuitive it's a integrated part of it, you find tons of solutions like futures and so on.
a PHP Future ? why ? every request 1 thread .... my request is the future...
And I am really good at PHP I've built concurrent systems, and generators coroutines using MQs to execute jobs and stream from a to b :). Still For a chat I will use nodejs because it's 2 libs and 20 lines of code. And other people will maintain those libs on regular basis :)