Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Node js info

Posted on 2013-12-05
12
Medium Priority
?
88 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 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 1600 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 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 1600 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 Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
LVL 15

Author Comment

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

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 1600 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 84

Accepted Solution

by:
Dave Baldwin earned 1600 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 400 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
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…
Suggested Courses

618 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