PhpStorm 2017.3 Help

Auto-Completing Code and Paths


Basic code completion. Completing names and keywords

Basic code completion helps you complete names of classes, methods, and keywords within the visibility scope. When you invoke code completion, PhpStorm analyses the context and suggests the choices that are reachable from the current caret position.

Code completion covers supported and custom file types. However, PhpStorm does not recognize the structure of custom file types and suggests completion options regardless of whether a specific type is appropriate in the current context.

If basic code completion is applied to part of a parameter, or a variable declaration, PhpStorm suggests a list of possible names depending on the item type.

To use basic code completion

  1. Start typing a name.

    The image below shows a suggestion list containing a variable name:


    The image below shows a suggestion list containing keywords:


To configure automatic code completion

You can configure PhpStorm to automatically invoke the suggestions list, without having to call basic completion explicitly.

  1. From the main menu select File | Settings (or press Ctrl+Alt+S).
  2. On the left choose Editor | General | Code Completion, and select the Autopopup code completion option.
  3. You can also select the Insert selected variant by typing dot, space, ect. option to use some keys to accept completion. These keys depend on the language, your context, etc.

    Note that while this setting helps you save time, turning it on may result in items being inserted accidentally.

Smart code completion. Completing code based on type information


To use smart code completion:




Completing statements

Complete statements enables you to create syntactically correct code constructs. This command inserts necessary syntax elements (parentheses, braces, semicolons etc.) and gets you in position where you can start typing the next statement.

To automatically complete a statement, start typing it. The punctuation required in the current context is added and the caret moves to the next editing position.

  • Completing code constructs: start typing a code construct and press Ctrl+Shift+Enter:
    web ide completing code construct 1

    PhpStorm automatically completes the construct, and the caret is placed at the next editing position:


  • : PhpStorm automatically encapsulates a method call when you directly type a new method call next to it.

    For example, type

    and then type the method call. When println gets the focus in the suggestion list, select it with Ctrl+Shift+Enter:
    The resulting code will look like the following:

Completing tag names

PhpStorm automatically completes tags and attributes names and values in the following file types:



If there is no schema association, PhpStorm will use the file content (tag and attribute names and their values) to complete your input.


Completing tag names

  1. Press < and start typing the tag name. PhpStorm displays the list of tag names appropriate in the current context. Use the ArrowUp and ArrowDown buttons to scroll through the list.
  2. Press Enter to accept a selection from the list.

    PhpStorm automatically inserts the mandatory attributes according to the schema.

Inserting a taglib declaration

  3. Select the desired taglib and press Enter. PhpStorm adds the declaration of the selected taglib:

Importing a taglib declaration

  2. Select a taglib from the list and press Enter.

    PhpStorm imports the selected taglib and adds the import statement automatically.

Hippie completion. Expanding words based on context



    • Press Alt+/ or choose Code | Completion | Cyclic Expand Word to search for matching words before the caret
    • Press Shift+Alt+/ or choose Code | Completion | Cyclic Expand Word (Backward) to search for matching words after the caret and in other open files.

Postfix code completion



function m(arg) { arg.if }



Completion tips and tricks

Narrow down the suggestions list

You can narrow down the suggestions list by typing any part of a word (even characters from somewhere in the middle), or invoking code completion after a dot separator. PhpStorm will show suggestions that include the characters you've entered in any positions.

This makes the use of wildcards unnecessary:


In case of CamelCase or snake_case names, type the initial letters only. PhpStorm automatically recognizes and matches the initial letters.

Accept a suggestion



View reference information

    web ide suggestion list documentation lookup

Sort entries in the suggestions list



View code hierarchy


  • Press Ctrl+H to view type hierarchy.
  • Press Ctrl+Alt+H to view call hierarchy.
  • Press Ctrl+Shift+H to view method hierarchy.

Completing a path


  3. Start typing a path. PhpStorm suggests a pop-up list where you can quickly find the needed directory:
  4. Select the relevant suggestion from the list.
Last modified: 29 March 2018

See Also


Getting Started: