In this tutorial, we’re going to show how to set a default PHP version for all new projects in JetBrains PhpStorm 2022.2.2. This is a really quick and easy setting to adjust if you want all new projects to be a particular version of PHP and have a default PHP CLI interpreter.
Before we start, take note of the current projects PHP version in the Status Bar along the lower right corner of the IDE software. The default, out-of-the-box configuration that PhpStorm uses is PHP version 5.6.
Step 01: Click On File > New Projects Setup > Settings for New Projects… Menu Option to Launch the Settings Dialog
This will launch the Settings dialog box where we can then edit the settings we want to apply to all new projects.
Step 02: Set PHP Language Level From Languages & Frameworks > PHP
We’re going to navigate in the Settings dialog box using the panel on the left. Expand the Languages & Frameworks menu then click on the heading PHP to bring up the options to change the PHP language level and CLI Interpreter. First select the dropdown next to the heading PHP language level and select the desired PHP version. In this example, I’m using PHP 8.1.
Step 03: Set CLI Interpreter For New Projects
From the dropdown next to the heading CLI Interpreter, select the desired PHP interpreter to use.
If you haven’t setup a PHP interpreter yet, you can skip setting one or leave on <no interpreter>.
Step 04: Uncheck Synchronize IDE Settings With Composer.json
Next, we need to tell PhpStorm to not look for composer.json files which override the project settings.
From the navigation on the left, make sure you expand the PHP menu, then click on Composer. Second, uncheck the box for Synchronize IDE Settings with composer.json. Finally, click OK to commit the changes to the settings in PhpStorm.
Step 05: Verify The Settings Work By Creating A New Project in PhpStorm
We’ll click on File > New Project… menu option to launch the New Project dialog box.
In the New Project dialog box, first enter a location in the file system where you want your new project to reside. You can also use the browse folder button on the right of the Location text box to bring up the Select Base Directory dialog box.
You can choose whatever location you want, but in my case I’m using XAMPP and will place my project in the default XAMPP directory.
Finally, click the Create button to finalize creating your new project.
Now you can verify that the default settings have been changed by looking at the PHP version in the status bar. It should match the value you previously set in Step 02.
And that’s all! What’s your favorite PhpStorm feature? What default settings do you like to use for your new PHP projects? Let us know in the comments and join the discussion.
All screenshots by Michael Smith.