简体   繁体   English

如何在 IntelliJ IDEA 中配置 Laravel 项目结构?

[英]How to configure Laravel project structure in IntelliJ IDEA?

Which folders I'm supposed to mark as Sources/Resources/Excluded?我应该将哪些文件夹标记为 Sources/Resources/Excluded?

在此处输入图片说明

My own logic based on the PHPStorm guide我自己的逻辑基于PHPStorm 指南

Sources来源

The root folder

reasoning : Your source code can be in mutliple folder inside the root.推理:您的源代码可以位于根目录内的多个文件夹中。

alternative : Just mark the real folder you have your code inside app, bootstrap, config, routes, (more...)替代方法:只需在app, bootstrap, config, routes, (more...)标记您的代码所在的真实文件夹app, bootstrap, config, routes, (more...)

Click this button to mark the selected folder as the root for namespaces used in your project.单击此按钮可将所选文件夹标记为项目中使用的命名空间的根目录。 Based on this setting, PhpStorm suggests you the proper folder name when you want to create a new namespace under another parent namespace during creation or moving a PHP class, that is, when you are actually creating or moving a PHP class to a non-existing namespace under another parent namespace.基于此设置,当您在创建或移动 PHP 类时想在另一个父命名空间下创建新命名空间时,即当您实际创建或移动 PHP 类时,PhpStorm 会建议您正确的文件夹名称另一个父命名空间下的命名空间。 If no Sources folder is specified, you will have to type the proper folder manually.如果未指定 Sources 文件夹,则必须手动键入正确的文件夹。

Appointing a Sources folder is not mandatory but this helps you keep your project structure in compliance with the PSR0 and PSR4 standards.指定 Sources 文件夹不是强制性的,但这有助于您保持项目结构符合 PSR0 和 PSR4 标准。 See Configuring PHP Namespaces in a Project for details.有关详细信息,请参阅在项目中配置 PHP 命名空间。

Tests测试

tests

reasoning : For obvious reasons your tests live there by default.推理:出于显而易见的原因,您的测试默认存在于那里。 It might be possible you use some test library for your javascript code that lives in another folder.您可能会对位于另一个文件夹中的 javascript 代码使用一些测试库。

Click this button to mark the selected folder as a test root.单击此按钮可将所选文件夹标记为测试根。

Excluded排除

vendor, storage, node_modules

reasoning : All (composer) libraries we use in our project live in vendor, but are not our own code.推理:我们在项目中使用的所有(作曲家)库都存在于供应商中,但不是我们自己的代码。 We should not search trough it by default.我们不应该默认搜索它。 In storage live caching files, files that have no significant meaning to us, we do not track them in version control (like vendor).在存储实时缓存文件中,对我们没有重要意义的文件,我们不会在版本控制中跟踪它们(如供应商)。 We could just delete them and the application would still work.我们可以删除它们,应用程序仍然可以工作。 Same for node_modules, but this directory is for javascript packages. node_modules 也一样,但这个目录是用于 javascript 包的。

Click this button to mark the selected folder as excluded so PhpStorm ignores it during indexing, parsing, and code completion.单击此按钮可将所选文件夹标记为已排除,以便 PhpStorm 在索引、解析和代码完成期间忽略它。

Resource Root资源根

public

reasoning : Your own frontend assets should be (somewhere) under the public folder to serve to the browser.推理:您自己的前端资产应该(某处)在公共文件夹下以提供给浏览器。 Frontend assets are (mostly?) files, javascript and css.前端资产是(主要是?)文件、javascript 和 css。

Click this button to enable PhpStorm to complete relative paths to resources under the selected folder.单击此按钮可以使 PhpStorm 完成所选文件夹下资源的相对路径。

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

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