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.

0
2 comments
Avatar
Permanently deleted user

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.

 

 

0

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

 

0

Please sign in to leave a comment.