I am new to VS code. I am trying to work with PHP, but I keep getting this notification.
phpcs: Request workspace/configuration failed with message:unable to locate phpcs. please add phpcs to your global path or use composer dependency manager to install it in your project locally.
Intellisense doesn't work for PHP too. I am using a Windows system. I tried to download and install Composer, but I am still getting the problem as shown in the screenshot.
]1
I have some extensions installed which are visible in the screenshot, but the issue persists.
In the Settings dialog, go to Editor > Inspections. From the inspections screen, expand the PHP | Quality tools node and enable “PHP CodeSniffer validation”. In the configuration pane that is now enabled, select “Custom” from the “Coding standard” dropdown, locate the ruleset configuration ( phpcs.
Open Visual Studio Code. Press Ctrl+P on Windows or Cmd+P on Mac to open the Quick Open dialog. Type ext install phpcs to find the extension. Press Enter or click the cloud icon to install it.
The easiest way is to use composer to install phpcs globally and symlink the binary into your path;
Assuming you have composer installed and are using osx or linux (if not, follow instructions from here: composer) then install phpcs globally: open your terminal and type:
composer global require "squizlabs/php_codesniffer=*"
You will then need to make sure phpcs is in your path. The easiest way is to symlink into /usr/local/bin. open your terminal and type:
sudo ln -s ~/.composer/vendor/bin/phpcs /usr/local/bin/phpcs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With