First, you need to download and install IDEA. Visit the official website, select the appropriate version for your operating system, and complete the installation.
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.
Once the plugin is installed, you'll need to configure it. Open “File” -> “Settings”, and choose the “PHP” tab on the left.
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.
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.
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.
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.
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.
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.