Your own Terminal in PhpStorm

How to add your preferred terminal to PhpStorm

By Bob Ray  |  September 3, 2024  |  6 min read
Your own Terminal in PhpStorm

Quite a while ago, I wrote a blog post on how to use Git Bash as your terminal in PhpStorm. I thought I'd update that article and make it more generic, so you can add any terminal to PhpStorm. I'll also talk a little about my preferred terminal and its advantages.

If you don't use Jetbrains' fabulous editor, PhpStorm, parts of this article probably won't interest you, though your preferred editor will almost certainly let you install an external terminal program with similar steps. This is essential if you want to "shell out" to a command line to run Grep or Sed, issuing Composer or Perl commands, creating an SSH link, running Git, unit tests, or Codeception, and many other things.

The following instructions are for PhpStorm and Git on Windows, but they will likely be similar for any other platform.

By default (the last time I checked), PhpStorm uses the Windows command-line shell (cmd) as the default terminal, but it's quite limited in what it can do. There are now much better options.

Installing your preferred Shell

My preferred shell (terminal client) is now Cmder. You can get it at that link. I recommend downloading the "Full" version since it comes with Git-for-Windows, which comes with all the Git Bash commands (grep, sed, Ssh, find, git, cat, etc.). It has nice highlighting, multiple themes, remembers previous commands, allows cutting and pasting, and provides some other nice features. It also includes clink, which has some more goodies like remembering commands between sessions and autocompletion (right-arrow accepts suggestion).

It's also possible to run PowerShell just by typing PowerShell at the terminal prompt. Typing exit will take you back to the original terminal.

To install it, just download from the link above, unzip the cmder.zip file somewhere, and run Cmder.exe. Important: right-click on the file and select "Run as administrator". You only need to do this on the first run. On that first run, it will install itself, and the supplemental programs, configure things, and adjust your Windows path (if necessary).

Configuring Cmder

Documentation for the terminal is somewhat scattered, since it is spread between Cmder, Git for Windows, ConEmu (the underlying terminal app), and Clink. Luckily, there's a huge settings menu in Cmder that will handle almost all configuration options. To get to it, right-click on bar at the top of the window and select "Settings."

I'd recommend setting the theme first. If you like the default Windows theme, consider yourself lucky. It appears to be the Monokai theme with a little extra brightness. On the "General" tab you'll see "Choose color scheme (next to the colored blocks). There are not many light themes. The Solarized Light theme is the most popular. For me, some of the themes removed the top bar, so it's good to know that you can launch settings screen with Win-Alt p, or Win-Alt t.

There's a nice preview of all the themes here.

I found that setting and saving various themes seemed to mess things up. Later themes had the wrong colors (sometimes everything ended up in a single text color, usually red, white, or black). At other times, I lost the Clink autosuggestions, and sometimes, the terminal failed to run in PhpStorm. A couple of times, I resorted to reinstalling Cmder to get things back to normal, so selecting your favorite theme from the screenshots, and choosing it in Settings may save you some trouble.

You can customize any of the themes by clicking on the "Colors" option in the Settings tree, but I don't recommend it unless you've got a lot of time on your hands. The customization process is complex, and changes I made often did not have the expected results.

On the General tab, you can also configure automatic updates. If you have it on, it will slow down launching the terminal a little, but I didn't notice the lag. If you do have it on, I'd recommend selecting the "Stable" option.

You can alter the size of the terminal window by dragging the right and/or bottom edge. Cmder will remember your preferred size by default, though you can turn this off in the settings.

Another change you might want to make is to the transparency setting. By default, opacity is not set to 100%, so you can see what's behind the terminal screen at all times. I'm not sure who would want that, but I hated it. To change it to total opacity, click on the "Transparency" option in the Settings tree (under "Features") and move the two sliders all the way to the right. I also changed the "Color-key transparency" to 1 1 1, though I'm not sure if that did anything.

There are a ton of other configuration settings. There's some information here, but it's far from complete. Luckily, most of the options are self-explanatory.

Don't forget to click on the "Save settings" button before leaving Settings, or your changes will be lost.

The Terminal in PhpStorm

When I first tried to set PhpStorm to use a shell, I kept playing with various PhpStorm settings for Command Line Tools, since that's the way I thought of Git. The fact is, though, the command line is a terminal client, and that's how PhpStorm thinks of it. To implement it, you have to go to:

File -> Settings -> Tools -> Terminal

Once you're there, here are the steps necessary to enable your preferred terminal in the Terminal dialog.

Put the following line in the Shell Path field (adjust as necessary for your platform and preferred terminal):

C:\path\to\cmder\directory\Cmder.exe

If there are spaces in the path, surround it with quotes.

As an alternative, you can click on the browse icon and navigate to the terminal's executable file, wherever it is.

I left all the checkboxes checked, except "Copy to clipboard." When you're done, click on "Apply" and then on "OK". You may have to restart PhpStorm for this all to take effect.

Setting the cursor type will have no effect if you're using Cmder, since it will be overridden by the Cmder setting (Features -> Text Cursor), which gives you way more control over what the cursor looks like.

You should now be able to launch the terminal by clicking on "Terminal" at the bottom of the PhpStorm project page (assuming the default configuration of the PhpStorm editor screen).

If you haven't already, you may also need to set the path to the Git executable. To see if you need to, just type git in the terminal. If it tells you there's no such command, go to:

File -> Settings -> Version Control -> Git

Bob Ray is the author of the MODX: The Official Guide and dozens of MODX Extras including QuickEmail, NewsPublisher, SiteCheck, GoRevo, Personalize, EZfaq, MyComponent and many more. His website is Bob’s Guides. It not only includes a plethora of MODX tutorials but there are some really great bread recipes there, as well.