3

My configuration / steps to reproduce the error:

  1. Installed Visual Studio Code Version 1.22.1
  2. Installed PHP CS Fixer Globally by: composer global require friendsofphp/php-cs-fixer
  3. Added Environment Variable: C:\Users\khalil\AppData\Roaming\Composer\vendor\bin\php-cs-fixer
  4. Verified running following command (php-cs-fixer). Output: Version: PHP CS Fixer 2.11.1 Grey Devil by Fabien Potencier and Dariusz Ruminski
  5. Installed Extension for vs-code: php cs fixer

Still getting the error: PHP CS Fixer: spawn php-cs-fixer ENOENT. executablePath not found

Note: I am on Windows 10 64bit

zarpio
  • 10,380
  • 8
  • 58
  • 71

2 Answers2

1

This is what worked out for me on Windows 10, modify if you have different folder structure.

"phpcbf.executablePath": "C:\\Users\\User\\AppData\\Roaming\\Composer\\vendor\\bin\\phpcbf.bat",
"phpcbf.executablePathWindows": "C:\\Users\\User\\AppData\\Roaming\\Composer\\vendor\\bin\\phpcbf.bat"

I am using phpcbf extension but yours is probably something like

"php-cs-fixer.executablePath": "C:\\Users\\User\\AppData\\Roaming\\Composer\\vendor\\bin\\php-cs-fixer.phar",
"php-cs-fixer.executablePathWindows": "C:\\Users\\User\\AppData\\Roaming\\Composer\\vendor\\bin\\php-cs-fixer.bat",
Ivan Topić
  • 3,064
  • 6
  • 34
  • 47
0

With Windows 10 & VS Code, You can use:

  1. Install Composer global & see: https://github.com/FriendsOfPHP/PHP-CS-Fixer#installation

  2. Add C:\Users{My Username}\AppData\Roaming\Composer\vendor\bin to PATH in System environment

  3. Use config:

    "php-cs-fixer.executablePath": "php-cs-fixer",

    "php-cs-fixer.executablePathWindows": "php-cs-fixer.bat",

Alex
  • 3,646
  • 1
  • 28
  • 25