Home > database >  How to auto import on enter in PhpStorm?
How to auto import on enter in PhpStorm?

Time:06-02

When I type Comment and press enter for the suggested class, I get \App\Models\Comment. Instead. I want to explicitly import it i.e. use App\Models\Comment.

enter image description here

CodePudding user response:

Since the auto import works in namespaced context (in a controller or model classes) then it must be that specific context setting.

  1. Settings (Preferences on macOS)
  2. Editor | General | Auto Import
  3. Make sure that PHP | Enable auto-import in file scope option is enabled.

enter image description here

  • Related