[英]IntelliJ IDEA / PhpStorm "Cannot resolve directory" for PHP project
Situation: I have the following PHP project structure:情况:我有以下 PHP 项目结构:
/images (contains images)
/views (contains .blade.php template files)
/vendor
composer.json
index.php
In a template I have an <img src="images/challenges/week3-food.jpg" />
.在模板中,我有一个
<img src="images/challenges/week3-food.jpg" />
。
Problem: IDEA marks "images" with a warning, saying "Cannot resolve directory 'images'".问题: IDEA 用警告标记“图像”,说“无法解析目录‘图像’”。
Elaboration: If I press Alt+Enter
, "Create Directory images", it creates an "images" folder under my /views
folder.详细说明:如果我按
Alt+Enter
,“创建目录图像”,它会在我的/views
文件夹下创建一个“图像”文件夹。
My goal: I want IDEA to understand that my project root is my webroot, and find my files there.我的目标:我想让 IDEA 知道我的项目根是我的 webroot,并在那里找到我的文件。 Basically, I want the warning gone and code completion work for my paths.
基本上,我希望警告消失并且代码完成对我的路径起作用。
What I tried: I went to File --> Project Structure --> Modules
and set my project root as Resource Root, with no luck.我尝试过的:我转到
File --> Project Structure --> Modules
并将我的项目根设置为资源根,但没有运气。
Screenshot: http://screencast.com/t/33mV4umA截图: http : //screencast.com/t/33mV4umA
Any advice on how to achieve this?关于如何实现这一目标的任何建议? I have had this issue on several other projects.
我在其他几个项目中遇到过这个问题。
In the screenshot you are doing images/challenges/week3-food.jpg
but should be /images/challenges/week3-food.jpg
(the slash in the beginning of the file path).在屏幕截图中,您正在执行
images/challenges/week3-food.jpg
但应该是/images/challenges/week3-food.jpg
(文件路径开头的斜杠)。
So it would be所以它会
<img src="/images/challenges/week3-food.jpg" />
PHPStorm should be able to read this as it should be in the images
directory of the root folder. PHPStorm 应该能够读取它,因为它应该位于根文件夹的
images
目录中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.