Solved

Node js info

Posted on 2013-12-05
12
73 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

733 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