You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Windows 10下通过Git Bash/命令行打开PhpStorm项目?

Hey there! I’ve been in your exact situation before—using Windows 10, Homestead, and PhpStorm 2017.3, and wanting to quickly fire up projects straight from Git Bash or the command line. Here’s how I got it working smoothly:

1. Add PhpStorm to Windows System Path

First, we need to make Windows recognize the PhpStorm executable from any command line window:

  • Locate your PhpStorm 2017.3 bin folder. The default path is usually C:\Program Files\JetBrains\PhpStorm 2017.3\bin
  • Open Windows Settings, search for Environment Variables, then click "Edit the system environment variables"
  • In the System Variables section, find the Path variable, click "Edit"
  • Click "New" and paste the full path to the PhpStorm bin folder, then save all windows
  • Test it: Open a regular Command Prompt and type phpstorm—PhpStorm should launch right away
2. Configure Git Bash to Use the phpstorm Command

Git Bash uses a Unix-style path system, so we’ll set up an alias to make it work seamlessly:

  • Open Git Bash and run this command to add the alias to your bash profile:
    echo 'alias phpstorm="phpstorm.exe"' >> ~/.bashrc
    
  • Refresh the bash profile to apply changes immediately:
    source ~/.bashrc
    
  • Now you can use it two ways:
    • Open the current directory as a project: phpstorm .
    • Open a specific project path (use Git Bash’s path format—replace C:\ with /c/): phpstorm /c/Users/YourUsername/Projects/your-awesome-project
3. Using PhpStorm from Homestead

If you’re working inside the Homestead VM, we need to connect it to your Windows PhpStorm instance via an X server:

  • First, install an X server tool like VcXsrv on your Windows machine. When launching it, make sure to check Disable access control
  • In Homestead, edit your shell profile (either ~/.bashrc or ~/.zshrc depending on your shell) and add these lines:
    export DISPLAY=host.docker.internal:0.0
    alias phpstorm="/mnt/c/Program\ Files/JetBrains/PhpStorm\ 2017.3/bin/phpstorm.exe"
    
  • Refresh the profile:
    source ~/.bashrc
    
  • Now you can open projects directly from Homestead: phpstorm /home/vagrant/code/your-project
Bonus Quick Tips
  • Open a single file directly in PhpStorm: phpstorm path/to/your-file.php (works in all command line environments)
  • If you ever forget the alias, just check your ~/.bashrc file to confirm the setup

内容的提问来源于stack exchange,提问作者Rasel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 03:56:41