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

PHP CS Fixer报错:spawn php-cs-fixer ENOENT,可执行路径未找到

Fixing "PHP CS Fixer: spawn php-cs-fixer ENOENT. executablePath not found" Error in VS Code

Problem Context

Here's the setup and steps that led to the error:

  • Installed Visual Studio Code version 1.22.1
  • Globally installed PHP CS Fixer via composer global require friendsofphp/php-cs-fixer
  • Added the path C:\Users\khalil\AppData\Roaming\Composer\vendor\bin\php-cs-fixer to system environment variables
  • Verified PHP CS Fixer works in terminal: running php-cs-fixer returns Version: PHP CS Fixer 2.11.1 Grey Devil by Fabien Potencier and Dariusz Ruminski
  • Installed the PHP CS Fixer extension for VS Code

Despite all this, the error persists:

PHP CS Fixer: spawn php-cs-fixer ENOENT. executablePath not found

Solutions to Try

1. Restart VS Code to Pick Up Environment Variables

New environment variables don't always get loaded into already-running apps. Close every instance of VS Code (even background processes you might miss) and reopen it. This gives the extension a chance to detect the updated PATH.

2. Manually Specify the Executable Path in VS Code Settings

If the extension still can't locate the executable, hardcode the full path in your VS Code settings:

  1. Open VS Code settings (File > Preferences > Settings, or press Ctrl+,)
  2. Search for php-cs-fixer.executablePath
  3. Set the value to the full path of your actual executable file. For your Windows setup, this is likely:
    C:\Users\khalil\AppData\Roaming\Composer\vendor\bin\php-cs-fixer.bat
    
    (Note: On Windows, Composer generates a .bat wrapper for global tools, so you need to point to that file instead of the bare php-cs-fixer entry)

3. Double-Check the Executable's Exact Location

Navigate to C:\Users\khalil\AppData\Roaming\Composer\vendor\bin in File Explorer and confirm php-cs-fixer.bat exists there. If the file has a different extension (like .phar), adjust your PATH and VS Code settings to match the correct filename.

4. Test in a Fresh Terminal Instance

Make sure you tested the php-cs-fixer command in a new terminal window after adding the environment variable—old terminals don't reload PATH automatically. If it works in the terminal but not VS Code, restarting the editor should bridge that gap.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 09:27:43