Visual Studio Code: Unable to locate phpcs

后端 未结 15 1843
梦毁少年i
梦毁少年i 2021-02-01 01:56

I am facing this issue in Visual Studio Code. I have already tried reinstalling the phpcs extension but still facing this issue.

Unable to locat

相关标签:
15条回答
  • 2021-02-01 02:14

    I had the same issue, I did the following to fix it:

    1. Install the phpcs by using composer with composer global require squizlabs/php_codesniffer

    2. Press Command + , (Click Code -> Preferences -> Settings)

    3. Select User Settings and locate 'PHP CodeSniffer'
    4. 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!

    0 讨论(0)
  • 2021-02-01 02:17

    In my case and in Windows 10, composer located at:

    C:\Users\{user_name}\AppData\Roaming\Composer\vendor\bin\
    

    and when i added this to VSCode settings at PHP CodeSniffer section this solve my problem.

    0 讨论(0)
  • 2021-02-01 02:19

    My solution without the need to install php_codesniffer globally.

    Just go to VSCode settings and define the local path ./vendor/squizlabs/php_codesniffer/bin/phpcs

    Or you can set the path directly in your settings.json

    "phpcs.executablePath": "./vendor/squizlabs/php_codesniffer/bin/phpcs"
    
    0 讨论(0)
  • 2021-02-01 02:20

    open the project in the terminal and run this command

    composer global require squizlabs/php_codesniffer
    

    Hope that helps!

    0 讨论(0)
  • 2021-02-01 02:22

    Install PHP Sniffer instead of phpcs

    PHP Sniffer worked on the fly without any extra configuration

    phpcs could not recognize my commands, despite a configured PATH, Composer & PHPCS installed.

    The commands were recognized in the terminal, but not by the plugin (under windows 10)

    0 讨论(0)
  • 2021-02-01 02:24

    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.

    1. Install Composer from this resource if you don't have it,
    2. After Composer is installed, open a command prompt wherever you want and run this command

      composer global require squizlabs/php_codesniffer
      
    0 讨论(0)
提交回复
热议问题