zarpio
zarpio

Reputation: 7338

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

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

Upvotes: 3

Views: 6441

Answers (2)

Alex
Alex

Reputation: 4266

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",

Upvotes: 0

Ivan Topić
Ivan Topić

Reputation: 3185

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",

Upvotes: 1

Related Questions