Can you use both PHP and Node.JS in a Project?

Is it possible to build part of your project in PHP and then other parts in Node.JS?

Would there be any benefit to this? Would you have to create 2 projects that would save to same site?

Thanks

1 Like

You can run node and PHP on same server, and even on the same port. The key is to use a server like nginx in front listening on port 80, set up PHP in Nginx as you normally would (using php-fpm) and set up your Node instance to listen locally on some high port like 8081.

Then just configure nginx to proxy all the Node requests through to localhost:8081 using the directory name as a filter. You’re essentially setting up nginx to treat Node requests a bit like it treats PHP requests: it forwards them off to some other daemon then handles the response as it comes back. Nginx is great at this and good at managing many connections at once.

Another benefit of this is that you can have multiple separate Node instances on different domains too, and use regular nginx rules to handle it all. You can also run it alongside other app servers like apps written in Go. And you can make it pretty secure too.

And you also benefit from Nginx’s configurability, its SSL and HTTP/2 support and huge speed in serving static files, and not having to serve static files from your Node app (if you don’t want to).

and you can check this link

1 Like

It is not possible in Wappler to have both PHP and NodeJS in a single project. You indeed have to create 2 separate projects for them, but you can have the same server as a target.

2 Likes

So basically want I am reading is if I want to use PHP and NodeJS in a single application I would have to have 2 separate projects in Wappler and I understand that. So I could do the front end mostly in PHP and then page a certain page in NodeJS, I could then link the NodeJS into the PHP project?

I think you may be headed in a direction of frustration by trying to mix them.

Out of curiosity, why not just use one or the other? If it is a project already started in one, what do you hope to gain by adding the other? Again, just a curiosity question.

I guess feel more comfortable with PHP and if I need to code something I feel like I could can get better support online than if I go NodeJS. I only need NodeJS for real-time data updates without client side interactions. The rest of the application is basic forms, data tables, api calls, etc…

Thanks for any insight

1 Like

nodejs applications can run as a background service. It can be used for this reason.

I had the same question to handle our back-end real time processing.
And just came to the conclusion that we would create a separate project with node, for real time back-end workflows, as we can’t afford to migrate everything under node for now.

Keeping php for the front-end is just fine usually.