Built-in web server not serving static files (PHP project)
Answered
I'm using IDEA Ultimate 2021.1 and am completely new to the IDE. I set up a very basic PHP project with some JS and CSS files in /js and /css respectively. However, the built-in web server does not serve the static files.
When I right-click a .php file and open > browser > safari, that file is served from http://localhost:63342. However, none of the .js or .css files is served.
Please help.
Please sign in to leave a comment.
I just recognised, that when I right-click and open the file, IDEA is actually attaching the project name as part of the path:
The URL it is calling in Safari is:
http://localhost:63342/myproject.io/index.php
where "myproject" is the project name. Obviously, this results in the browser not being able to resolve /css and /js as the "myproject.io" part must not be part of the URI.
That's a limitation of a built-in webserver. To workaround this try using fully fledged web servers, e.g. XAMPP. Here's a guide about this: https://www.jetbrains.com/help/phpstorm/installing-an-amp-package.html