How do I get PHPStorm to use the correct path for CSS?

时光总嘲笑我的痴心妄想 提交于 2019-12-31 07:19:24

问题


I have been using "Delphi PHP XE2". The file structure has worked fine for over a year on the development machine and the production.

The folders are organised as follows.

src/app_login.php
src/add
src/css
src/js
src/fnc
src/db
src/images

etc.

I am just trying out PHPSTORM. The include files work fine. When I run it in Firefox it can find all images, JavaScript files, etc. But it can not find the CSS files as it is looking for them in

css

rather than

src/css

I haven't changed anything.

  1. Why is the browser now looking at absolute path rather than relative?
  2. How did PHPStorm manage to tell it that?
  3. And how do I coerce it to treat them as relative paths?

I see that in the browser it runs it as:

http://localhost:63342/SRC/app_login.php

instead of

http://localhost:63342/app_login.php

I guess this the problem. How do I coerce it to move down one directory level?

I am trying to set up IIS, I think this might be best for later on. Here are the screen shots:

I configured the hosts file so that when I type wys.com in the browser it tries to run it and shows a blank page. If I type in 192.168.1.0 it just shows a blank page. View Source shows nothing. I was expecting it to run the index.html at d:\wys\src. Why is the browser not running it?


回答1:


You are using PhpStorm's own simple built-in web server which uses URLs like http://localhost:63342/ProjectName/app_login.php. You cannot make http://localhost:63342/app_login.php using such server as it will not be able to tell what files to serve.

Either use your own Apache/IIS/whatever web server .. or the best you can get with built-in server would be http://ProjectName:63342/app_login.php(IDE needs to know what site/files to serve somehow). For that:

  1. Edit your hosts file (or local DNS server, if preferred and have one) and point ProjectName to your computer's IP (e.g. 127.0.0.1).

  2. Create Deployment entry of correct type (In Place should do), configure it (provide desired URL etc -- http://ProjectName:63342/) and mark it as Default for this project -- now IDE will use URL from there when generating "open in browser" URLs.



来源:https://stackoverflow.com/questions/30053204/how-do-i-get-phpstorm-to-use-the-correct-path-for-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!