Solved

Node js info

Posted on 2013-12-05
12
71 Views
Last Modified: 2015-05-01
Hi,

I am Newbie in node.js. I want to know how to integrate it into php. I have install node js in windows. If possible please do let me know how to run it in browser . Tried to run below code but when run on browser it downloads the page. Do i have to install some other package like memcache and so on . Using xampp on windows .

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello Node.js\n');
}).listen(8124, "www.test.com");
console.log('Server running at http://www.test.com:8124/');
0
Comment
Question by:Insoftservice
  • 6
  • 4
  • 2
12 Comments
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 400 total points
ID: 39699266
Node.js is used to make servers, not to be used in them.  Please read the info here: http://nodejs.org/  I do not believe that Node.js can run PHP or in PHP.
0
 
LVL 15

Author Comment

by:Insoftservice
ID: 39700151
So, if i want to implement it on browsers how to do that.
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 400 total points
ID: 39700234
Node.js does not run in a browser.  It runs on the server and is used to create the server functions.

Regular javascript runs in your browsers, not Node.js.
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 15

Author Comment

by:Insoftservice
ID: 39705516
But how to execute node.js then and utilize it in server
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 400 total points
ID: 39705533
You have to install it in your server.  Then you can use the examples on http://nodejs.org/ to create useful functions.
0
 
LVL 15

Author Comment

by:Insoftservice
ID: 39705914
tried but when tried to execute the example it downloads the page.
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 400 total points
ID: 39706559
Using Node.js is not as simple as writing a web page.  You have to make use of the libraries that exist to create a web server that will understand page requests.  There are a lot of examples there and you will just have to work thru them.
0
 
LVL 15

Author Comment

by:Insoftservice
ID: 39714894
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello Node.js\n');
}).listen(8124, "www.test.com");
console.log('Server running at http://www.test.com:8124/');

As per question i had tried with some examples but instead of giving me o/p its downloading the page
0
 
LVL 43

Assisted Solution

by:Rob
Rob earned 100 total points
ID: 40529671
Are you still having issues with Node?  I've since started using it quite a bit and can offer some assistance if necessary?
0
 
LVL 15

Author Comment

by:Insoftservice
ID: 40565793
yes i still had the issue . but had currently stopped using it. but would surely try it out today or tomorrow from scratch .
0
 
LVL 43

Expert Comment

by:Rob
ID: 40565800
Post your issues and I'll have a crack for you
0
 
LVL 15

Author Closing Comment

by:Insoftservice
ID: 40755514
Sorry I am too busy to do RND on node js . But surely if i get time i will try to  work on it again.
Thanx all for ur valuable comments .
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question