0

I'm using PhpStorm 2016.3.3 in Windows 10 and I'd like to know how can I launch it from my terminal?

For example execute command pstorm . to open current project, or pstorm . --add to add current project folder to PhpStorm.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
bashkovpd
  • 598
  • 1
  • 7
  • 21
  • Generally speaking: https://www.jetbrains.com/help/phpstorm/2016.3/working-with-phpstorm-features-from-command-line.html – LazyOne Mar 15 '17 at 13:38
  • 1
    I'm not sure that `pstorm .` will work (the `.` part) -- at least in the past it did not worked for sure as `.` gets interpreted by actual PhpStorm.exe which will loose that info at that point (the current folder). If it would be interpreted by batch script or alike then it may convert `.` into full folder name. Because the general command is `PhpStorm.exe full\path\to\the\folder-or-file` – LazyOne Mar 15 '17 at 13:42
  • *"or `pstorm . --add` to add current project folder to PhpStorm." What do you mean by that exactly? Adding such folder as Additional Content Root to currently active project? Opening that project as subproject (or whatever it's properly called)? Or making new project from that folder? First of all -- there is no `--add` param. Secondly -- when you pass a folder as a parameter, PhpStorm will either open existing project (if `.idea` sub folder is present) or will create brand new one from those files. – LazyOne Mar 15 '17 at 13:45

2 Answers2

1

Create a PowerShell Alias "pstorm". Inside your PowerShell profile you can add something like:

New-Alias pstorm "C:\Program Files\JetBrains\PhpStorm 2018.3\bin\phpstorm64.exe"

You'll need to replace the path in the quotation marks above with your own path to where the phpstorm executable was installed on your PC.

If you don't have a PowerShell profile, the first thing you'll need to do is create a PowerShell profile. Here’s how you setup your profile.

First, you can see that the $profile variable is populated, and points to a file.

PS C:\> $profile
C:\Users\Michael\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

But that file doesn’t actually exist

PS C:\> test-path $profile
False

See? Crazy. So I need to create the profile. I use new-item to do this, and use the $profile variable to define where I’m creating the item

PS C:\> new-item $profile -force
Type: file

The “-force” parameter really helps. It means “create this item and if any part of the directory tree doesn’t already exist then create that too.” Very nice. I forgot to add the “-type” for the new-item command, so it prompted me for it. I left that in there so you can see what it looks like if you forget. To create it properly, I should have done “new-item $profile -force -type file”. Either way, we get the result:

Directory: C:\Users\Michael\Documents\WindowsPowerShell
Mode                LastWriteTime     Length Name
—-                ————-     —— —-
-a—         5/27/2010  10:32 PM          0 Microsoft.PowerShell_profile.ps1

The profile has been created! Since it’s a .ps1 file, we can invoke our default .ps1 editor by using Invoke-Item.

PS C:\> ii $profile

“ii” is an alias for invoke-item. It means “open the file with the default program”. Invoke-item on a .txt file or .ps1 and it opens in your default editor. Then you can add the new alias line mentioned previously, save the file and restart PowerShell. You should then be able to execute command pstorm . to open current directory in PhpStorm.

gchristo234
  • 158
  • 3
  • 11
0

There is no way to create cmd launcher on Windows (there is a feature request for this option, https://youtrack.jetbrains.com/issue/IDEA-114307). If you like to start Phpstorm from command prompt, open cmd console, cd to install dir and run either phpstorm.exe or phpstorm.bat. If you like to start it from any directory, add %PS_install_dir%/bin to your system %PATH%

See also https://www.jetbrains.com/help/phpstorm/2016.3/opening-files-from-command-line.html#d201968e62

lena
  • 90,154
  • 11
  • 145
  • 150