PhpStorm 2017.2 Help

Auto Import

File | Settings | Editor | General | Auto Import for Windows and Linux
PhpStorm | Preferences | Editor | General | Auto Import for macOS
Ctrl+Alt+S /help/img/idea/2017.2/settings.png


XML

Show import pop-upAutomatically display an import pop-up dialog box when typing the name of an unbound namespace.

TypeScript/JavaScript

Add ES6 imports automatically
  • If this check box is selected, PhpStorm automatically inserts an import statement in JavaScript code when you complete a symbol exported using ES6 exports in another project file:
  • When the check box is cleared, on pressing Alt+Enter PhpStorm shows a pop-up that suggests to import the completed symbol:
    ws_es6_autoimport_off.png
  • Completion and autoimport also work for React components, including stateless components. PhpStorm properly detects them, provides code completion, and adds import statements automatically:
Add TypeScript imports automatically
  • If this check box is selected, PhpStorm automatically inserts an import statement in TypeScript code when you complete a symbol exported in another project file.
  • When the check box is cleared, on pressing Alt+Enter PhpStorm shows a pop-up that suggests to import the completed symbol.

PHP

Enable auto-import in file scopeSelect this check box to have PhpStorm automatically import PHP namespaces, add use statements, and complete short class names on the fly, when you are typing in a class or file that does not belong to any specific namespace. By default, the check box is cleared.
Enable auto-import in namespace scopeSelect this check box to have PhpStorm automatically import PHP namespaces, add use statements, and complete short class names on the fly when you are typing in a class or file that belongs to a certain namespace. The check box is selected by default.
Enable auto-import from global space

When this check box is selected, PhpStorm automatically adds use statements for classes, functions, and constants from the global namespace, for example, Exception, is_array(), strlen() etc.
When this check box is cleared, no use statement for such classes, functions, and constants is added. By default, the referenced symbol is not prepended with a backslash. To have a backslash inserted automatically, select the Prepend functions and constants from the global space with '\' check box.

Prepend functions and constants from the global space with '\' The check box is available only when the Enable auto-import from global space is cleared. When the check box is selected, PhpStorm automatically prepends called functions and referenced constants from the global namespace with a backslash.
When the check box is cleared, no backslashes are added.
To keep your code easy to read and increase productivity by avoiding additional loops during name resolution, select either the Enable auto-import from global space or the Prepend functions and constants from the global space with '\' checkbox. See PHP name resolution rules for more details.
Last modified: 12 October 2017

See Also