2

sorry to bother you, but I've been looking for answers and I couldn't find them anywhere... Well i'm a fresh dude in the field of javascript and node.js and here's my problem:

I've created an application based on the tutorial of socket.io - Here's the link to the completed project of their chat example. everything is working as it should, but I would really need to trigger somekind of a command while node server is running... command should be triggered via php script.

The command should trigger an emit event - so every client in our case would see a new message sent via php.

I saw couple of suggestions to do it from another server with php/using cURL. The problem is that I don't know how to fetch POST data sent from php to node.js server.

Any solution to command node with php is more than welcome and again i'm sorry to bother you :)

3
  • 1
    Are you trying to communicate with your NodeJS application via PHP ? Something like a PHP script sending data to NodeJS ? Commented Apr 23, 2015 at 6:24
  • Exactly! Node application should recieve data from php. I don't think that it is possible to give command to node.js server while it is running directly or? Commented Apr 23, 2015 at 6:27
  • 1
    just look up "how to upload file node.js" and it will cover all you need to know about buffering the incoming POST data. from there, you just pass it to socket.io. i know you don't actually need to handle files, but the process is the same and those tutorials are focused... Commented Apr 23, 2015 at 6:56

1 Answer 1

1

You can use a bridge to exchange data between NodeJS and PHP. You will need to implement a PHP server that exposes remote procedures and a NodeJS client that calls those remote procedures. You can send any data to the NodeJS application from PHP using these remote procedures.

Here are a few links to get you started:

http://bergie.iki.fi/blog/dnode-make_php_and_node-js_talk_to_each_other/

https://github.com/bergie/dnode-php

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.