作者:加菲猫fd | 来源:互联网 | 2023-05-30 11:52
ImnewtoPHPStormandalreadyranintoaproblemwhichkillsmywilltousetheIDE:我是PHPStorm的新手
I'm new to PHPStorm and already ran into a problem which kills my will to use the IDE:
我是PHPStorm的新手,已经遇到了一个问题,这个问题会影响我使用IDE的意愿:
I write paths to images in css like
我用CSS编写路径到图像
background-image: url(/CSS/Img/separator.png);
That is the correct path that the IDE will accept without throwing an error.
这是IDE在不抛出错误的情况下接受的正确路径。
Then I run the website and get the error
然后我运行网站并得到错误
GET localhost:63342/CSS/Img/separator.png 404 (Not Found)
GET localhost:63342 / CSS / Img / separator.png 404(未找到)
That's understandable, because the file is at
这是可以理解的,因为该文件位于
localhost:63342/ProjectName/CSS/Img/separator.png
So I'm guessing I need to configure something. I tried to google for a solution, but I honestly don't even know what to search for.
所以我猜我需要配置一些东西。我试图谷歌寻求解决方案,但老实说,我甚至不知道要搜索什么。
2 个解决方案
0
Alright, I finally made it work!
好吧,我终于成功了!
Many thanks to LazyOne for getting me on the right path and providing me with this useful link on how to configure PHPStorm with XAMPP!
非常感谢LazyOne让我走上了正确的道路,并为我提供了有关如何使用XAMPP配置PHPStorm的有用链接!
This was a step in the right direction, but not everything I needed to get it to work. The main fault is of course with me, because I am new to this IDE and didn't know my way around. Finally, to get it working I had to do two more steps:
这是朝着正确方向迈出的一步,但不是我需要让它发挥作用的一切。主要的错误当然是我,因为我是这个IDE的新手并且不知道我的方式。最后,为了让它工作,我不得不再做两个步骤:
Make a new run-configuration for PHP with built-in Webserver.
使用内置Webserver为PHP创建新的运行配置。
Upload my project to the server root, which is "D:\xampp\htdocs\PROJECT_NAME" in my case
将我的项目上传到服务器根目录,在我的案例中是“D:\ xampp \ htdocs \ PROJECT_NAME”
(I'd post links for the other steps, but I don't have enough reputation here)
(我会发布其他步骤的链接,但我在这里没有足够的声誉)
Then when you hit "Run", it just opens the debug window and does nothing. This is where you'd expect the IDE to open up a browser for you, but you gotta do it yourself and input the right path. In my case it is now "localhost:80/index.php". It's a bit weird, but at least it works now! :)
然后当你点击“运行”时,它只是打开调试窗口而什么都不做。这是您希望IDE为您打开浏览器的地方,但您必须自己动手并输入正确的路径。在我的情况下,它现在是“localhost:80 / index.php”。这有点奇怪,但至少它现在有效! :)