Closed Narretz closed 11 years ago
Hi there
Can you please recheck the phpcs aspect of the above. I've just pushed some changes that may or may not help.
With regards to the last comment about 'Linter' being turned off. I've looked into this and I think you mean you have turned it off for the on_save aspect, but if you right click and "Sniff this file" then it runs all code checking activities.
For Narretz' last issue, he means why is it running at all if he's set the _run pref to false in his config. I've submitted a pull request to fix that.
@Narretz make sure you set phpcs_executable_path properly with escaped backslashes on Windows, otherwise the plugin won't find it.
@Narretz - @rys's fix is now on the master branch, so there is now a couple of commits that will hopefully sort some of your issues out. If you are using Package Control you should get the update pulled down for you, if not just perform a git pull on the master branch for this repo.
Okay, now only the Code Sniffer runs when I execute the command, thanks for the fix.
Unfortunately, I still get the 0 errors message in Sublime, while the sniffer finds errors when I use the command line.
What's strange is that the plugin seems to find the sniffer, but if fails in actually finding th errors. Maybe there is something wrong with my directory structure; I have my phpcs.bat in the php folder, but the actual sniffer files are in the pear folder.
I was right, I had a problem with my CodeSniffer installation. The bat file didn't correctly point to the php.exe. Oddly enough, it worked in the console when I was in the folder with the phpcs.bat, but not in any other folder. So this was my mistake. However, is there the possibility to display the errors in the ST console that come from phpcs.bat? This would help debugging greatly.
Regarding the php cs fixer, I now get a plugin error:
[Phpcs] c:\wamp\bin\php\php5.3.13\php-cs-fixer.phar fix C:\wamp\www\videocloud_api\src\Magix\Videocloud\ApiBundle\Controller\VideosController.php --verbose --level=all
Traceback (most recent call last):
File ".\sublime_plugin.py", line 362, in run_
return self.run(edit)
File ".\phpcs.py", line 513, in run
File ".\phpcs.py", line 382, in fix_standards_errors
File ".\phpcs.py", line 99, in get_errors
File ".\phpcs.py", line 198, in execute
File ".\phpcs.py", line 201, in parse_report
File ".\phpcs.py", line 112, in shell_out
File ".\subprocess.py", line 633, in __init__
File ".\subprocess.py", line 842, in _execute_child
WindowsError:
This may or not may be Windows saying that it cannot execute the .phar file
I am getting a similar error message:
File ".\threading.py", line 532, in __bootstrap_inner
File ".\threading.py", line 484, in run
File ".\phpcs.py", line 318, in run
File ".\phpcs.py", line 99, in get_errors
File ".\phpcs.py", line 157, in execute
File ".\phpcs.py", line 160, in parse_report
File ".\phpcs.py", line 112, in shell_out
File ".\subprocess.py", line 633, in __init__
File ".\subprocess.py", line 842, in _execute_child
phpcs works from the command line in the folder that has the file I am checking.
I have the same issue as @simpleenigma does. I've tried supplying all sorts of paths to get it to find php and phpcs, but no luck. Maybe all we need is a sample settings file for windows that works. In the README it is said that this plugin has been tested in Win XP? @benmatselby could you kindly share that file in the repo, maybe?
I keep seeing this error: "WindowsError: [Error 2] The system cannot find the file specified".
Searching for this error yielded this link: http://stackoverflow.com/q/5324107/443219
Hi guys,
The configuration I have when testing on Windows (I only have access to 7 now, so will update the README) is:
{
// Plugin settings
// Turn the debug output on/off
"show_debug": true,
// Which file types (file extensions), do you want the plugin to
// execute for
"extensions_to_execute": ["php"],
// Execute the sniffer on file save
"phpcs_execute_on_save": true,
// Show the error list after save.
"phpcs_show_errors_on_save": true,
// Show the errors in the gutter
"phpcs_show_gutter_marks": true,
// Show outline for errors
"phpcs_outline_for_errors": true,
// Show the errors in the status bar
"phpcs_show_errors_in_status": true,
// Show the errors in the quick panel so you can then goto line
"phpcs_show_quick_panel": true,
// The path to the php executable.
// Needed for windows, or anyone who doesn't/can't make phars
// executable. Avoid setting this if at all possible
"phpcs_php_prefix_path": "C:\\Program Files (x86)\\PHP\\php.exe",
// Options include:
// - Sniffer
// - Fixer
// - Mess Detector
//
// This will prepend the application with the path to php
// Needed for windows, or anyone who doesn't/can't make phars
// executable. Avoid setting this if at all possible
"phpcs_commands_to_php_prefix": ["Fixer"],
// PHP_CodeSniffer settings
// Do you want to run the phpcs checker?
"phpcs_sniffer_run": true,
// Execute the sniffer on file save
"phpcs_command_on_save": true,
// It seems python/sublime cannot always find the phpcs application
// If empty, then use PATH version of phpcs, else use the set value
"phpcs_executable_path": "C:\\Program Files (x86)\\PHP\\PEAR\\phpcs.bat",
// Additional arguments you can specify into the application
//
// Example:
// {
// "--standard": "PEAR",
// "-n"
// }
"phpcs_additional_args": {
"--standard": "PEAR",
"-n": ""
},
// PHP-CS-Fixer settings
// Fix the issues on save
"php_cs_fixer_on_save": false,
// Show the quick panel
"php_cs_fixer_show_quick_panel": true,
// Path to where you have the php-cs-fixer installed
"php_cs_fixer_executable_path": "C:\\Program Files (x86)\\PHP\\PEAR\\php-cs-fixer.phar",
// Additional arguments you can specify into the application
//
// Example:
// {
// "--level": "all"
// }
"php_cs_fixer_additional_args": {
"--level": "all"
},
// PHP Linter settings
// Are we going to run php -l over the file?
"phpcs_linter_run": true,
// Execute the linter on file save
"phpcs_linter_command_on_save": true,
// It seems python/sublime cannot always find the php application
// If empty, then use PATH version of php, else use the set value
"phpcs_php_path": "",
// What is the regex for the linter? Has to provide a named match for 'message' and 'line'
"phpcs_linter_regex": "(?P<message>.*) on line (?P<line>\\d+)",
// PHP Mess Detector settings
// Execute phpmd
"phpmd_run": false,
// Execute the phpmd on file save
"phpmd_command_on_save": true,
// It seems python/sublime cannot always find the phpmd application
// If empty, then use PATH version of phpmd, else use the set value
"phpmd_executable_path": "",
// Additional arguments you can specify into the application
//
// Example:
// {
// "codesize,unusedcode"
// }
"phpmd_additional_args": {
"codesize,unusedcode,naming": ""
}
}
This covers off issues with spaces in filenames as well. This configuration works on Sublime Text 2 and 3, with spaces in filenames and application paths on Windows 7.
Thanks for the file! I've copied this verbatim into the phpcs.sublime-settings file, except for changing the location string of php.exe and phpcs.bat to the right paths.
I now see this error:
Exception in thread Thread-686:
Traceback (most recent call last):
File ".\threading.py", line 532, in __bootstrap_inner
File ".\threading.py", line 484, in run
File ".\phpcs.py", line 316, in run
File ".\phpcs.py", line 99, in get_errors
File ".\phpcs.py", line 267, in execute
File ".\phpcs.py", line 270, in parse_report
File ".\phpcs.py", line 112, in shell_out
File ".\subprocess.py", line 633, in __init__
File ".\subprocess.py", line 842, in _execute_child
WindowsError: [Error 2] The system cannot find the file specified
What might be the problem?
Did you restart Sublime Text 2?
Glory unto the lord! That worked! Sorry, and thank you very very much.
When I get time to investigate and correctly resolve GH-58 so there is no performance issue, you will not have to restart Sublime, as that is an awful user experience.
Does this resolve everybody elses issues? If so I will close
@adityamenon As mentioned on twitter, I will knock up a "how to" with settings files for various platforms etc. This will be later in the week
Cool, it works! the problem was
// This will prepend the application with the path to php
// Needed for windows, or anyone who doesn't/can't make phars
// executable. Avoid setting this if at all possible
"phpcs_commands_to_php_prefix": ["Fixer"],
In hindsight, it makes a lot of sense to set this, but it just didn't become clear for me while reading the config / manual. :)
Just one question:
When in the config is set:
"php_cs_fixer_show_quick_panel": false,
and I execute the fixer from Command Palette, the file is not updated and the fixes are not immediately visible. I have to tab out of the fil and back to see the changes. When I save, the sniffer shows me the same errors.
When the setting is true, the quick panel pops up, I select it, and the file is updated immediately.
There is still another small bug there: when I press escape in the quick panel, I expect that the fixing is aborted, but it is actually executed regardless.
@Narretz The secondary issues are related to how the the quick panel works and renders within Sublime Text from what I can tell.
And lastly, the question around pressing escape to undo the changes. The only way this really can be implemented is using the --dry-run feature in php-cs-fixer to show you what it will do before executing. If you would like this can you please raise another issue so it isn't lost amongst all these comments.
Closing this issue down.
I have been having this issue and finally changed one line to find out that the child command "Sniff this file" started working. Here is the line: "phpcs_executable_path": "C:\Program Files (x86)\PHP\v5.6\phpcs.bat",
Hope this helps!
when the following setting is enabled
"php_cs_fixer_additional_args": {
"--level": "all"
},
fixer is throwing the following error
[InvalidArgumentException]
The level "all" is not defined.
other than this, the provided setting file works great on ST3 in Win 7
Sorry to bother you again with Windows issues. This is more or less a reminder for myself that it probably won't work next time I'll try.
Win 7 Professional 64-bit SP1 WAMP Server 2.2 PHP 5.3.13 Sublime 2.0.1 / fresh portable PHPCS: 2013.01.08
Question: Is `"phpcs_php_prefix_path"`` correctly configured? I'll find the docs very vague in this respect without an example.
Another one: In the console, why does the plugin report "Linter found 0 errors", "MessDetector found 0 errors" even if I have them turned off? It's confusing.