简体   繁体   English

如何使PHPStorm为CSS使用正确的路径?

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

I have been using "Delphi PHP XE2" . 我一直在使用"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 . 我只是在尝试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 当我在Firefox中运行它时,它可以找到所有图像,JavaScript文件等。但是由于在其中寻找CSS文件,因此找不到它

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? PHPStorm如何做到这一点?
  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. 我正在尝试设置IIS ,我认为这可能是以后最好的选择。 Here are the screen shots: 以下是屏幕截图:

伊斯绑定

Iss设置

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. 我配置了主机文件,以便在浏览器中键入wys.com时尝试运行该文件并显示空白页。 If I type in 192.168.1.0 it just shows a blank page. 如果我输入192.168.1.0它只会显示一个空白页。 View Source shows nothing. 查看源什么都没有显示。 I was expecting it to run the index.html at d:\\wys\\src . 我期望它在d:\\wys\\src上运行index.html Why is the browser not running it? 为什么浏览器无法运行?

You are using PhpStorm's own simple built-in web server which uses URLs like http://localhost:63342/ProjectName/app_login.php . 您正在使用PhpStorm自己的简单内置Web服务器 ,该服务器使用诸如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. 您无法使用此类服务​​器创建http://localhost:63342/app_login.php ,因为它将无法确定要提供的文件。

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). 使用您自己的Apache / IIS /任何Web服务器..或使用内置服务器获得的最佳效果是http://ProjectName:63342/app_login.php (IDE需要知道以何种方式提供服务的站点/文件) 。 For that: 为了那个原因:

  1. Edit your hosts file (or local DNS server, if preferred and have one) and point ProjectName to your computer's IP (eg 127.0.0.1 ). 编辑您的hosts文件 (或本地DNS服务器,如果需要的话,有一个),然后将ProjectName指向计算机的IP(例如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. 创建正确类型的Deployment条目 (应In Place进行),进行配置(提供所需的URL等http://ProjectName:63342/并将其标记为该项目的Default -现在IDE在生成时将使用那里的URL “在浏览器中打开” URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM