Closed longstorycorte closed 3 months ago
Hi, first of all welcome to web dev ;)
Secondly, it looks like your index.php is located in the /src folder, so based on you configuration you would need to access it in the web browser via http://localhost:3000/src/index.php. The proper configuration field root (to avoid the src prefix in the url) for Vite still needs to be implemented, see issue https://github.com/donnikitos/vite-plugin-php/issues/10. For this plugin you do not need the VS Code extensions, only a real PHP server binary. Server starting/ killing, compilation and auto reload will be handled automatically.
But besides that all for an even more simple start you can use our starter repository: https://github.com/nititech/php-vite-starter
I'm having some troubles setting up
vite-puglin-php
. It s my first time usingvite
and usingnpm
workflow in general, but i managed to make it work with regular html and everything its working fine (i started a fresh new project with nothing else then vite and this plugin). Now i want to switch tophp
, i followed plugin's documentation and set myvite.config.js
as below, but i cant make it work. I'm not even sure about a simple thing (since i'm new to this workflow): till now i was developing php using live server + PHP sever extensions in VScode, do i still need them? Cause i also searched for other solution and following some of them (envolvingvite-plugin-live-reload
for example) (none of which worked for me) and they were talking about changing port invite.config.js
to match thephp
one (i assumed the one u can set in PHP sever extension indeed, u can even see some comments left from a piece of code i copyed).Here's my
vite.config.js
:And my project structure:
(i already checked this Issue)
At this point i dont get any error if i only run via
npm run dev
but the browser says it cant find any page at localhost:3000, but if i serve the project via PHP sever before everything else i get this error:All the other combination of starting the 2 extensions in different orders gives no error but still not working.
I hope it is not a completely noob question but i m strugglin a lot and i already search everything about php in vite. I also hope i gave right amount of info. Thank U.U