cytopia/devilbox

[Howto]: Use PHP and Vite simultaneously in the same project

musicraccoon opened this issue · 2 comments

Have you already checked elsewhere?

What are you struggling with?

I want to use both PHP and Vite in the same project.
When switching to the browser, it should open index.php , inside which is connected localhost:5173/@vite/client .

If you run Node JS inside shell.sh , nothing works, and if run outside the container, everything works.

I tried to set up reverse proxying, then Vite opens in the browser, but it doesn't work index.php

(Windows 11 + WSL2)

What have you tried already?

What is your goal?

@musicraccoon what seems to be the errors you are getting? I am doing this all the time.
in php container accessed via shell.sh you can even use nvm to instal different version of node. Before you have to make folder writeable or you'll get errors:

sudo chmod -R 777 /opt/nvm/
nvm install node
Downloading and installing node v21.1.0...
Downloading https://nodejs.org/dist/v21.1.0/node-v21.1.0-linux-arm64.tar.xz...
################################################################################################################################ 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v21.1.0 (npm v10.2.0)

nvm use node
Now using node v21.1.0 (npm v10.2.0)

node -v
v21.1.0

then inside project dir:

cd project
npm i
node index.js