How to teach express to run php?

Hello! Guys, a question:
I'm using express + webpack to build the project and now I need to send Ajax requests to php files. Is there any options how to do it in express (express is only used in Virgo) or maybe somehow a proxy to adjust for these axow?
July 9th 19 at 10:38
3 answers
July 9th 19 at 10:40
You mix it all together and in the end nothing is clear.
-------
If I understand you correctly, you need to send GET/POST requests from your node.js application application PHP.
--------
If so, then this is done as follows
var request = require('request')
var url = 'http://www.google.com' // input your url here

// use a timeout value of 10 seconds
var timeoutInMilliseconds = 10*1000
var opts = {
 url: url,
 timeout: timeoutInMilliseconds
}

request(opts, function (err, res, body) {
 if (err) {
console.dir(err)
return
}
 var statusCode = res.statusCode
 console.log('status code:' + statusCode)
})
July 9th 19 at 10:42
July 9th 19 at 10:44
Express does not work with php. This is actually node.js framework. Want to work with PHP use Open Server for example.
why to answer such stupid questions. The person should refer to the program on php programs on the GBR. - Pansy.Fe commented on July 9th 19 at 10:47
: Learn how to start a Russian speaking - pinkie_Collins commented on July 9th 19 at 10:50
by : question title is already clear that the man has no clue. Him about the REST and then painted. - pinkie_Collins commented on July 9th 19 at 10:53
: so stupid here is you. Because the answer should be based on the level of the person asking the question. - pinkie_Collins commented on July 9th 19 at 10:56
: : .=)))))))) - mercedes commented on July 9th 19 at 10:59
: I'm not Russian. and it is not going to learn English better in English though there is something valuable in the network )) I I I I I Will continue to write errors and I do not care for the comments of the pundits like you - Pansy.Fe commented on July 9th 19 at 11:02
: just because of these answers account for a couple of times to raise the same question. and in General if not specific answers, but there is a strong desire to help. it is better to write in the comments. - Pansy.Fe commented on July 9th 19 at 11:05
: As express is node.js framework? I thought he was written in the css.... - Prince commented on July 9th 19 at 11:08
: I have a project written in reacte. And suddenly I server Prager says he will temporarily to use PHP on the server side. Well, I have and there is a need to teach express executeth php. Why the outrage-then all sorts breed? - Prince commented on July 9th 19 at 11:11
: I'm not Russian, but if you're here on a Russian forum and write in Russian with mistakes, you SSZB. - pinkie_Collins commented on July 9th 19 at 11:14
: First of pretender should, in principle, to stand such a task. Second time You ask such questions then something is clearly not right in your Kingdom. - pinkie_Collins commented on July 9th 19 at 11:17
: got no problem with it )) - Pansy.Fe commented on July 9th 19 at 11:20
: have I asked the question about whether it is right? I asked how can I make so-and-so. If so asked, it means to me for some reason so you need to do now. Can I dispute? What do you care? While I'm waiting for will make the rest API and set the server, I need to do a few experiments. Would you just reply and not rush here with their opinions? - Prince commented on July 9th 19 at 11:23
: And I'm not saying that it is wrong. It is impossible in principle. Ajax requests to php files are not sent. They are sent to the server. And there is spinning on the server does not matter to the one who sends the request. - pinkie_Collins commented on July 9th 19 at 11:26
they are sent to the file because the server for them, i.e. vnikuda. That's why I asked this question to make/expand the server for processing data queries. I have PHP for Apache, the only question is how to sponsirovat Express on Apache, for example. I was expecting a response in the spirit of "Ekspress can not expand, but it can be sponsirovat on any server on Apache. Here's how you can do this...". Why do I here theory in the spirit of "requests to the files do not go, go to server". No brainer that they go to the server, but if server no? Where do they go? Vnikuda. Please respond directly if interested. You know how to sponsirovat requests to local Apache server? If not, then thank you enough. - Prince commented on July 9th 19 at 11:29
: if you have Apache, it should work basic pipe:
app.use((req, res) => {
req.pipe(http.request({
 method: req.method
 path: req.path
 port: APACHE_PORT
 }, apacheRes => apacheRes.pipe(res)));
});
- Kelsie.Purdy commented on July 9th 19 at 11:32
: the answer is oddly enough the answer. Read it again. It says about Open Server. - pinkie_Collins commented on July 9th 19 at 11:35
: oddly enough, but this is not the answer. Re-read the question again - Prince commented on July 9th 19 at 11:38
: Yes, thank you) - Prince commented on July 9th 19 at 11:41

Find more questions by tags PHPJavaScriptWebpackExpress.js