Current Location: Home> Latest Articles> How to Set Up a PHP Development Environment in IDEA: Complete Guide

How to Set Up a PHP Development Environment in IDEA: Complete Guide

gitbox 2025-06-17

How to Set Up a PHP Development Environment in IDEA

1. Download and Install IDEA

First, you need to download and install IDEA. Visit the official website, select the appropriate version for your operating system, and complete the installation.

2. Install the PHP Plugin

After installing IDEA, the next step is to install the PHP plugin. Open IDEA, go to “File” -> “Settings”, and in the settings window, click on “Plugins”.

Search for the PHP plugin in the “Browse Repositories” section, install it, and restart IDEA once the installation is complete.

3. Configure the PHP Plugin

Once the plugin is installed, you'll need to configure it. Open “File” -> “Settings”, and choose the “PHP” tab on the left.

3.1 Configure the PHP Interpreter

In the “PHP” settings page, click the “+” button on the left side, and in the pop-up window, select a PHP interpreter.

You can choose “From Remote” (to get it from a remote server) or “Local” (to use a local PHP installation). If you choose “Local”, specify the local PHP directory; if you choose “Remote”, configure the server, SSH port, username, password, and PHP interpreter details. After configuring, click “Test” to ensure the setup is correct and save the settings.

3.2 Set PHP Code Style

Under the “PHP” tab, go to “Editor” -> “Code Style” -> “PHP”. Here, you can adjust code indentation, spaces, punctuation, and other style settings to ensure consistent coding style.

3.3 Configure the PHP Server

In the same settings window, go to the “Servers” tab. Here, you can add, delete, or modify your PHP server settings, including configuring file paths, domains, URIs, and other relevant information. Ensure everything is set up correctly.

4. Create a New PHP Project

After installing and configuring the PHP plugin, you can now create a new PHP project. Go to “File” -> “New” -> “Project”, select PHP as the project type, and complete the necessary configurations to create the project.

5. Edit PHP Code

After the project is created, you can start writing PHP code. Right-click on the project folder, select “New” -> “PHP File” to create a new PHP file, and start coding.


      <?php
        echo "Hello, world!";
      ?>
    

6. Run PHP Code

Once you've written the code, go to the “Run” menu at the top of IDEA and select the appropriate PHP server from the dropdown list to run your code.

Then, you can open your browser and input the corresponding URI to see the output of your PHP code.

With that, your PHP development environment is set up! You’ve learned how to install and configure the PHP plugin in IDEA, how to set the PHP code style, how to create a PHP project, and how to write and run PHP code.