skip to Main Content

Recently I updated my VS code on my macOS. I’m now running vs code version 1.41.1.

Ever since the reinstall, the phpfmt extension is no longer working and giving me the

phpfmt: php_bin “php” is invalid`

pop up every time I save a file.

I tried removing VS code and installing it again. I removed the extension and reinstalled it as well yet I am still getting this error.

Is there any other settings i can clear. I can’t find this error anywhere online.

5

Answers


  1. assuming you have PHP installed:

    Edit your vscode settings (JSON view) add this option:

    "phpfmt.php_bin": "php"

    If you want auto formatting on save:

    All Languages:

    "editor.formatOnSave": true

    Just PHP:

    "[php]": { "editor.formatOnSave": true }

    you can always check out the plugin page too:

    https://marketplace.visualstudio.com/items?itemName=kokororin.vscode-phpfmt

    has this bits of info on this + further configuration

    happy coding!

    Login or Signup to reply.
  2. On Mac Os:

    In the vscode settings (JSON view) extend the ^^ above option with the Mac Os PHP path:

     "phpfmt.php_bin": "/usr/bin/php"
    

    Cheers

    Login or Signup to reply.
  3. Just add below code in setting.json in VS Code

    "phpfmt.php_bin": "C:/xampp/php/php.exe"
    

    in my case the location is in xampp so just add your php.exe location.

    Login or Signup to reply.
  4. You have to find dir to file php.exe and then you can fig that easily by this way below:
    "phpfmt.php_bin": "F:/Xampp/php/php.exe",

    F:/Xampp/php/php.exe – my directory

    Login or Signup to reply.
  5. "phpfmt.php_bin": "C:/xampp/php/php.exe"
    
    • open setting.json in VS code
    • You have to find your php.exe path and paste it after "phpfmt.php_bin": "php.exe path"
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search