Visual Studio Code: Unable to locate phpcs
I am facing this issue in Visual Studio Code. I have already tried reinstalling the phpcs extension but still facing this issue.
Unable to locate phpcs
Please add
phpcs
to your global path or use the composer dependency manager to install it in your project locally in Visual studio Code
Solution 1:
I had the same issue, I did the following to fix it:
Install the phpcs by using composer with
composer global require squizlabs/php_codesniffer
Press
Command + ,
(Click Code -> Preferences -> Settings)- Select User Settings and locate '
PHP CodeSniffer
' -
Scroll to '
Executatble Path
' and put/Users/your-username/.composer/vendor/bin/phpcs
This fixed the issue for me, I hope it does for you too. Cheers!
Solution 2:
open the project in the terminal and run this command
composer global require squizlabs/php_codesniffer
Hope that helps!
Solution 3:
I think uninstalling it does not solve the issue.
i had the same issue. So,
- Go to extensions and install the plugin...."phpcs".
- Search for the extension if you had install it.
- Disable the extension.
it resolved the issue in my VS code.
Solution 4:
On Debian based systems run as root:
apt-get install php-codesniffer
Solution 5:
From a GitHub comment.
If someone still needs help about this "Unable to locate phpcs ..." error message, try this: you just need to install
phpcs
globally via Composer.
- Install Composer from this resource if you don't have it,
After Composer is installed, open a command prompt wherever you want and run this command
composer global require squizlabs/php_codesniffer