bashkovpd
bashkovpd

Reputation: 598

PhpStorm launcher

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.

Upvotes: 0

Views: 232

Answers (2)

gchristo234
gchristo234

Reputation: 158

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.

Upvotes: 1

lena
lena

Reputation: 93728

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

Upvotes: 0

Related Questions