如何在 PhpStorm 中输入时自动导入?
How to auto import on enter in PhpStorm?
当我键入 Comment
并按回车键输入建议的 class 时,我得到 \App\Models\Comment
。反而。我想明确导入它,即 use App\Models\Comment
.
由于自动导入在命名空间上下文中工作(在控制器或模型中 类),因此它必须是特定的上下文设置。
Settings (Preferences on macOS)
Editor | General | Auto Import
- 确保
PHP | Enable auto-import in file scope
选项已启用。
当我键入 Comment
并按回车键输入建议的 class 时,我得到 \App\Models\Comment
。反而。我想明确导入它,即 use App\Models\Comment
.
由于自动导入在命名空间上下文中工作(在控制器或模型中 类),因此它必须是特定的上下文设置。
Settings (Preferences on macOS)
Editor | General | Auto Import
- 确保
PHP | Enable auto-import in file scope
选项已启用。