PHP reference
The page and all the pages under this node are available only when the PHP plugin is enabled. The PHP plugin is not bundled with IntelliJ IDEA, but it can be installed on the Settings | Plugins page, tab Marketplace, as described in Installing plugins from JetBrains Marketplace.
Use this page to configure PHP development and unit testing support in the project by choosing one of the available PHP interpreters.
Item | Tooltip / Shortcut | Description |
---|---|---|
PHP language level | In this list, specify the PHP functionality scope to get coding assistance for. Each functionality scope is associated with the PHP version that supports this functionality. Currently PHP 5.3, PHP 5.4, PHP 5.5, PHP 5.6, PHP 7, PHP 7.1, PHP 7.2, PHP 7.3, PHP 7.4, PHP 8.0, PHP 8.1, and PHP 8.2 levels are supported. For more information, refer to supported PHP versions. There is no enforced correlation between the PHP version used in the project and the PHP language level configured in IntelliJ IDEA. Although the language version of each interpreter is detected automatically, you can still tell IntelliJ IDEA to provide you with coding assistance that corresponds to a different language level. However, if you attempt to use a code construct that is not supported by the specified language level, IntelliJ IDEA suggests a Switch to PHP <version> quick-fix. When you open an existing project, IntelliJ IDEA analyzes it for the language features used and sets the appropriate language level automatically. | |
CLI Interpreter | In this list, choose the PHP interpreter to use in the current project by default. The list contains all the currently configured local and remote PHP interpreters. For more information, refer to Configure local PHP interpreters and Configure remote PHP interpreters. | |
Shift+Enter | Click this button next to the CLI Interpreter list to create a new IntelliJ IDEA-wide PHP installation configuration in the CLI Interpreters dialog that opens. For more information, refer to Configure local PHP interpreters and Configure remote PHP interpreters. | |
Path mappings | When you configure a remote interpreter accessible through SFTP, Vagrant, Docker, or WSL this read-only field shows the path mappings retrieved from the corresponding deployment configuration, Vagrantfile, or Dockerfile. These mappings are read-only. To provide the custom mappings, click next to the field and specify them in the Edit Project Path Mappings dialog that opens:
|
Include Path tab
The area displays the list of configured include paths. Include paths are used for holding libraries, that is, third-party code that is used for completion and reference resolution in some functions/methods that use file paths as arguments, for example, require()
or include()
.
Use and to add and remove folder paths.
Select a folder and click Exclude to exclude the contents of this folder from indexing.
PHP Runtime tab
The area lists the available PHP stubs, which are normal, syntactically correct PHP files containing annotated function, method, and class signatures, constant definitions, and so on. PHP stubs are added to IntelliJ IDEA's internal knowledge to enhance coding assistance for all the Standard PHP Library components as well as for common extensions.
Use the checkboxes next to each item to enable/disable the corresponding stub.
To load the set of stubs that matches the set of loaded extensions for the currently configured CLI interpreter, click the Sync Extensions with Interpreter button. For more information about configuring interpreters, refer to Configure local PHP interpreters and Configure remote PHP interpreters.
In the Project tool window, the currently loaded stubs are displayed under the External Libraries node.
Advanced Settings area
If necessary, you can load a set of custom PHP stubs to be used by IntelliJ IDEA. Click next to the Default stubs path field and provide the stubs folder location in the dialog that opens. This way, you can load additional IntelliJ IDEA stubs as well as override the bundled ones.
PHP stubs are available as a Composer package, and can thus be declared and installed as a dependency for some third-party package. In this case, they are stored under the vendor/jetbrains/phpstorm-stubs folder inside your project.
To prevent conflicts between the Composer package stubs and IntelliJ IDEA bundled stubs, do one of the following:
To use the Composer package stubs in your project, explicitly provide the path to their location in the Default stubs path field.
To use the IntelliJ IDEA's bundled PHP stubs, make sure that the Default stubs path field is cleared and the vendor/jetbrains/phpstorm-stubs folder is excluded from the project.
If the Add packages as libraries option is enabled on the page of the Settings dialog (Ctrl+Alt+S) , IntelliJ IDEA automatically marks the vendor/jetbrains/phpstorm-stubs folder as excluded. By default, the option is enabled.
If the Add packages as libraries is disabled, you can exclude the stubs package folder manually. To do this, in the Project view, right-click the
vendor/jetbrains/phpstorm-stubs folder and select from the context menu.
Analysis tab
Use this tab to configure the behavior of certain IntelliJ IDEA inspections.
Exception Analysis
Use this section to configure exception analysis, which alters the behavior of the Unhandled exception, Redundant catch clause, Missing @throws tag(s), and Redundant @throws tag(s) inspections.
Item | Tooltip / Shortcut | Description |
---|---|---|
Call tree analysis depth | Use this list to set the desired exception analysis depth level. By default, 1 is selected, in which case IntelliJ IDEA reports the unhandled exceptions for the parent method throwing an exception, as well as the methods directly calling it. Selecting larger values allows you to drill down deeper into the calls hierarchy. If 0 is selected, the exception analysis is limited to the parent method. | |
Skip calls with constant params | Select this checkbox to have IntelliJ IDEA skip certain method calls in the instance creation expressions during exception analysis:
| |
Unchecked Exceptions | Use this list to specify the exceptions that are treated as unchecked by IntelliJ IDEA. Such exceptions are skipped during exception analysis. | |
Alt+Insert | Click this button to add a class to the Unchecked Exceptions list. In the Choose Class dialog that opens, locate the desired class by using the Search by Name tab or the Project tab. | |
Delete | Click this button to remove a selected class from the Unchecked Exceptions list. |
Custom Format Functions
Use this section to include your custom string formatting functions into the Format function parameters mismatch inspection analysis scope. This inspection reports the mismatches between format function parameters and specification conversion entries and by default analyzes the usages of the standard PHP printf and sprintf functions.
Item | Tooltip / Shortcut | Description |
---|---|---|
Alt+Insert | Click this button to add a new function record to the custom format function list. In the Add Custom Format Function dialog that opens, provide the name of a class method or function and specify the index of the argument where your formatting template resides. | |
Delete | Click this button to remove a function record from the custom format function list. | |
Enter | Click this button to edit the selected function record. |
Include Analysis
Use this section to define a custom folder the $_SERVER['DOCUMENT_ROOT']
expression should resolve to, which alters the behavior of the Unresolved include inspection.
The specified path will be used in code completion for the functions/methods that use file paths as arguments (for example, require()
or include()
). If the path is left blank, code completion will suggest the paths relative to the project root.
Commonly, this setting should be modified in case the document root folder defined by your web server configuration is different from the IntelliJ IDEA project root folder.
Item | Description |
---|---|
$SERVER['DOCUMENTROOT' | In this field, provide the folder the The default value is blank: the |