cytopia / devilbox

A modern Docker LAMP stack and MEAN stack for local development
http://devilbox.org
MIT License
4.37k stars 652 forks source link

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

Open musicraccoon opened 11 months ago

musicraccoon commented 11 months ago

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?

-

guycalledseven commented 10 months ago

@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
agathasweb commented 1 month ago

I have the same problem as I reported in the post:

https://github.com/cytopia/devilbox/issues/1028

If I use the reverse proxy as instructed in the Devilbox documentation, everything that depends on node works perfectly. But PHP stops working!