Open yeahlife opened 6 years ago
What is the output of php -v
?
I am having same issue in vs code and this is what I got after command execution:
$ php -v PHP 7.2.4 (cli) (built: Mar 28 2018 04:27:01) ( ZTS MSVC15 (Visual C++ 2017) x64 ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Thanks!
I think it's the same problem as https://github.com/ikappas/vscode-phpcs/issues/119
phpcs version:
$ phpcs --version PHP_CodeSniffer version 3.3.0 (stable) by Squiz (http://www.squiz.net)
Please Let me know how to solve this out.
I solved the problem like this : https://github.com/ikappas/vscode-phpcs/issues/119#issuecomment-395696586
same issue
I had same issue but blackfire was breaking it because it was loaded 2x in php.ini.
In my situation, running phpcs --version
shows in the top line a warning message:
Warning: Xdebug MUST be loaded as a Zend extension in Unknown on l
PHP_CodeSniffer version 3.5.2 (stable) by Squiz (http://www.squiz.net)
So, first I solved Xdebug
issue.
The second thing is make sure from the path:
C:\Users\USER_NAME\AppData\Roaming\Composer\vendor\bin\phpcs.bat
I just spent the whole day checking all of the internet to get this fixed while I ignored something quite important (simply because it is unrelated to phpcs). I am using phpcs 3.5 but you should try this too no matter the version.
Really, this issue (of phpcs running in the command line but not working in vscode and giving the invalid string encountered error) is usually not a problem from phpcs or from vscode (especially when the error is invalid string encountered). I had to read the linter.js file to see where this error is coming from.
So, to fix this: First, run the command phpcs --version
and check if the command does not print any warning or error before outputting a line similar to PHP_CodeSniffer version x.x.x (stable) by Squiz (HTTP://www.squiz.net)
.
If any error or warning (usually unrelated to phpcs) is thrown before the line showing the version, please go fix that warning or error first. According to linter.js, it expects that the first output (when it executes the phpcs.bat) must start with the PHP_CodeSniffer version
string. Thus, If anything prints before the PHP_CodeSniffer version ...., then it throws the error.
So, You MUST fix any warning or error printed before the phpcs version if you want phpcs to work in VSCode. Also, ensure the path is properly set and follow all other fixes above too. So, I hope this fix works for you. cheers!
phpcs: Unable to locate phpcs. Invalid version string encountered!
what should i do ?