Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Loots's avatar
Level 4

Mixing php with nodejs

Hi, for a small portion of my webapp, I want to use NodeJs. But I'm wondering where to place the files. I'm guessing I should just put them in a new directory of resources? It's only a small script (that includes a small local server) that should run using puppeteer, so it won't be a big subproject. I know it doesn't matter for functionality, but I want to keep my project as clean as possible. The resources directory seems like an ok solution, but it doesn't seem great either.

I'm not sure if it matters, but I want to use nodejs to create pdf documents. Because the free php alternatives are not that great and have a lot of restrictions.

0 likes
3 replies
marbobo's avatar

if I were you I'll just put it on root directory and isolate it from other laravel files. some thins like this.

/app
/bootstrap
/config
/database
/nodeServer
/resources
...
...
andyabihaidar's avatar
Level 3

Would make sense to put it outside your project as well. I'm assuming the node application will be running on a different port, and you can just call that whenever needed. Would be more maintainable as well to just mark it as it's own little project instead of a sub-project. Just a personal preference though.

Please or to participate in this conversation.