PhpStorm 2016.2 Help

Configuring Folders Within a Content Root

In this section:

Overview

Within a content root, PhpStorm can distinguish between the folders that contain source code, and the ones to be ignored while searching, parsing, watching etc. To do so, you can mark any folder below a content root as a source folder, or as excluded so it becomes invisible for PhpStorm.

Within a content root, PhpStorm can distinguish between Source folders, Resource Root folders, Test Source code, and Excluded folders.

The folder marked as Source is hte root folder for all the PHP namespaces in the current project.

Files under a folder marked as Resource Root can be referenced relative to this folder. Excluded folders are not involved in indexing and therefore they are ignored while searching, parsing, watching etc.

To invoke this distinction, you can mark any folder below a content root as Source, Resource Root, Test, or Excluded.

Marking directories

You can assign a folder to a category in two different ways:

To mark directories under the content root:

  1. Open the Settings / Preferences Dialog by pressing Ctrl+Alt+S or by choosing File | Settings for Windows and Linux or PhpStorm | Preferences for OS X. Click the Directories node.
  2. In the Directories page, click the desired content root. The directories under this content root are displayed as a tree view in the right-hand pane.
  3. Select the directory you want to mark and do one of the following:
    • To have PhpStorm consider the contents of the selected folder as unit tests, click the Tests toolbar button rootTest.png or choose Test Sources on the context menu of the selection.
    • To have PhpStorm consider the selected folder as the root for namespaces used in your project, click the Sources toolbar button rootSource.png o choose Sources on the context menu of the selection.

      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. If no Sources folder is specified, you will have to type the proper folder manually.

      Appointing a Sources folder is not mandatory but this helps you keep your project structure in compliance with the PSR0 and PSR4 standards. See Configuring PHP Namespaces in a Project for details.

    • To have PhpStorm ignore the selected directory during indexing, parsing, code completion, etc., click the Excluded toolbar button rootExcluded.gif or choose Excluded on the context menu of the selection.
    • To enable PhpStorm to complete relative paths to resources under the selected folder, click the Resource Root toolbar button rootResource.png or choose Resource Root on the context menu of the selection.
    wi_mark_directory_excluded.png

To mark directories using the context menu:

  1. Right-click the desired directory in the Project Tool Window.
  2. On the context menu, point to Mark Directory As node.
  3. Choose Mark as <directory status>.

Unmarking directories

To return a folder to its regular status, do one of the following

  • On the Directories page of the Settings / Preferences Dialog:
    • Select the directory in question in the list of folders under the content root, and click rootUnmark:
      unmarkContentRoot
    • Click the folder's status icon once more.
    • Choose the corresponding command on the context menu of the directory.
  • In the Project Tool Window, right-click the desired directory, point to Mark Directory As node, and then choose Unmark as <directory status>.
>

See Also

Last modified: 24 November 2016