IntelliJ IDEA 2016.2 Help

Enabling PHP Support in a Project

On this page:

Creating an empty PHP project

  1. Choose File | New | Project on the main menu or click the New Project button on the Welcome screen. The Project Category and Options dialog opens.
  2. In the left-hand pane, choose PHP, in the right-hand pane, choose PHP Empty Project, then click Next.
  3. On the second page of the wizard:
    • In the Project Name text box,
    • In the Project Location text box, specify the path to the project folder where the project-related files will be stored.
    • In the PHP Language Level drop-down list, specify the PHP functionality scope to get coding assistance for. Each functionality scope is associated with PHP version that supports this functionality. Currently PHP 5.3, PHP 5.4, PHP 5.5, PHP 5.6, PHP 7, and PHP 7.1 levels are supported.

      No correlation between the PHP version used in the project and the language level is enforced. 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 another 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.

    • From the Interpreter drop-down list, choose the PHP interpreter to use in the current project. The list contains all the currently configured local and remote PHP interpreters. See Configuring Local PHP Interpreters and Configuring Remote PHP Interpreters for details. You can also choose an interpreter or configure a new one later, see .
    • The Include Path area shows a list of paths to PHP-related items below the PHP home directory. The specified include paths will be used:
      • By the require(), include(), fopen(), file(), readfile(), and file_get_contents() functions when looking for files to use.
      • By IntelliJ IDEA when resolving references to included files.

      Use the Add new.png  and Remove  delete.png buttons to manage the contents of the list. Use the Up arrowUp  and Down  arrowDown  buttons to change the order of items in the list.

    When you click Finish, IntelliJ IDEA generates a project stub and opens it either in the current window or in a new one depending on your choice in the information dialog box that opens: Refer to the section Opening Multiple Projects for details.

See also Configuring PHP Namespaces in a Project

Creating a PHP project from existing sources

Besides creating an empty PHP project, you can re-use your previously developed sources.

  • When the files to re-use are already on your machine, all you need is just open the folder where they are stored:
    1. On the main menu, choose File | Open.
    2. In the dialog box that opens, select the folder where the required sources are stored.
  • When the files to re-use are on a remote host:
    1. Configure synchronization with this remote host, see Configuring Synchronization with a Web Server.
    2. Download the sources to re-use, see Uploading and Downloading Files.
    3. Open the folder where the downloaded sources are stored and thus arrange them in a IntelliJ IDEA project. Alternatively, create an empty IntelliJ IDEA project and copy the downloaded source to it.

Choosing the PHP interpreter and the language level manually

To start PHP development in a project, you need to appoint one of the previously configured local or remote PHP interpreters to use and choose the PHP language level which determines the scope of PHP functionality to get coding assistance for. Currently PHP 5.3, PHP 5.4, PHP 5.5, PHP 5.6, PHP 7, and PHP 7.1 levels are supported.

To use PHP-related items from outside your project content root, configure include paths as described in Configuring Include Paths.

If you created your project through the New Project dialog, you have already specified the language level and possibly the interpreter and the include paths. However, if your project was created around some existing sources, you need to specify these settings manually.

  1. Open the Settings / Preferences Dialog by pressing Ctrl+Alt+S or by choosing File | Settings for Windows and Linux or IntelliJ IDEA | Preferences for OS X, and click PHP under Languages&Frameworks. Open the PHP page: choose File | Settings and in the Settings dialog box that opens, click PHP under Languages & Frameworks.
  2. In the PHP page that opens, choose the PHP installation to use from the Interpreter drop-down list.
    • To make sure that the configuration you have chosen points at the relevant installation, click the Reload button refresh.png  next to the drop-down list. If no PHP engine is actually installed at the specified directory, IntelliJ IDEA displays the corresponding error message.
    • Click the Show phpinfo button to have IntelliJ IDEA display a separate information window where you can examine the installation details and view the list of loaded extension and configured options. Please note that the options specified in the Configuration Options field of the Interpreters dialog box are not listed.
  3. In the PHP language level drop-down list, specify the PHP functionality scope to get coding assistance for. Each functionality scope is associated with PHP version that supports this functionality. Currently PHP 5.3, PHP 5.4, PHP 5.5, PHP 5.6, PHP 7, and PHP 7.1 levels are supported.

    No correlation between the PHP version used in the project and the language level is enforced. 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 another 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.

See Also

Last modified: 23 November 2016