PHP
Last modified: 10 August 2022warning
The following is only valid when the PHP plugin is installed and enabled.
PHP support includes:
Possibility to create PHP files and classes from templates.
Full 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, and PHP 8.1 syntax support.
Syntax and error highlighting.
Resolution of
include
statements and file references, including references to PHAR archives.All the PHAR files from the current project and the specified include path are shown in the project tool window under the Project View/Libraries/PHAR node and available for browsing right there.
Class Completion
Intention actions and quick fixes
Surrounding with code constructs Ctrl+Alt+J and Ctrl+Alt+T.
Jump to declaration Ctrl+B.
PHP development support is provided through the PHP plugin. The PHP plugin is not bundled with IntelliJ IDEA, but it can be installed on the Settings/Preferences | Plugins page, tab Marketplace, as described in Installing plugins from JetBrains repository.
This part describes some procedures that are specific for developing PHP applications and some preliminary steps that are required to configure PHP development environment.
To develop an application using PHP
Follow these general steps:
Configure PHP interpreters as described in Configuring Local PHP Interpreters and Configuring Remote PHP Interpreters.
Start creating a project from scratch. On the first page of the New Project wizard, choose PHP in the left-hand pane, then choose PHP Empty Project in the right-hand pane.
tip
To run and debug your application on a local Web server, create the project root below the Web server document root. Thus your application sources will be "visible" for the local Web server.
Create and configure the required data sources (see Manage data sources).
Populate the application using provided coding assistance.
Deploy the application.
tip
With IntelliJ IDEA, you can flexibly configure deployment of PHP applications. For example, you can set up your PHP project on a local Web server from the very beginning, or develop and test an application locally and then upload it to a remote Web server, and so on.
Run the application. You can do it in several ways:
From IntelliJ IDEA using a run configuration of the type PHP Web Page to view application output in a browser.
From IntelliJ IDEA using a PHP Script run configuration to view the application output in the Run tool window.
From IntelliJ IDEA, using a built-in Web server. This approach saves your time and effort because you do not need to deploy the application sources.
The following optional steps may be helpful:
Set up unit testing in your project.
Install and configure a debugging engine and specify the debugger options, see Configure a debugging engine and Debugger for details.
Debug the application.
Thanks for your feedback!