Skip to main content

phpcs issue in Visual Studio Code, I'm receiving this warning in VS Code:

phpcs: Unable to locate phpcs. Please add phpcs to your global path or use composer decency manager to install it in your project locally.

 

How to fix

You can install phpcs by using composer global command:

composer global require squizlabs/php_codesniffer

Then in VS Code, go to 

Click Code -> Preferences -> Settings

Select User Settings and locate 'PHP CodeSniffer', or in the Search settings enter 'codesniffer'

Scroll down to 'Executatble Path' and add the following

/Users/{yourname}/.composer/vendor/bin/phpcs

Remember to replace {yourname} with machine user name

 

Different issue, similar problem

Now the issue is

phpcs: Unable to locate phpcs. Command failed: /Users/{your name}/.composer/vendor/bin

 

How to fix

Restart VS Code

Related articles

Andrew Fletcher17 Oct 2023
Managing VS Code extensions via terminal
Visual Studio Code (VS Code) allows you to manage extensions using the VS Code Command Line Interface (CLI) called code. With the code CLI, you can install, list, uninstall, and manage extensions from the command line.  To check you have the code prompt running, runcode --versionResponse you're...
Andrew Fletcher29 Sep 2023
How to install PHP 8.1 on Ubuntu 20.04
Update Ubuntu 20.04To begin update the server using the commandsudo apt update && sudo apt upgrade -yFor more details about this process see How To Update All Packages Linux. PHP versionCheck the current PHP version usingphp -vThe response I had wasPHP 7.4.3 (cli) (built: Nov 2...
Andrew Fletcher13 Feb 2023
brew changing PHP versions on OSX
Installing PHP on OSX and it installed PHP 8.2.x.  However, for my applications I need to run 8.1.x.  How do you switch the current PHP version?   Current version Check the current PHP version by executing the command php -v Response: PHP 8.2.2 (cli) (built: Feb ...