Open perholmes opened 7 years ago
OK, it seems to actually be installed, there's just so little feedback anywhere that I didn't realize it. I now enabled logging, and I can see it's running. Now I just need to find out why it's not touching the files. Is my existing formatting really that good? Anyway, seems to be working.
@perholmes you’re not alone.
this plugin is piece of shit doesnt work even if you install everything and use older version.
@Tommixoft fork it and improve it.
it have to be fixed, cause its not working, improvements should be done when item works. I see no reason keeping non working stuff in git :) It would be great if it would work, and thanks for your tie, but the fatc is fact-it doesnt work.
There where 3 things that got it working for me.
The default phpformatter.arguments is incorrect set to empty in settings.json. "phpformatter.arguments": [], I can see there is a pull request in for it.
Also for me when I installed php-cs-fixer via composer. There is no php-cs-fixer.par file, just php-cs-fix. So I use: "phpformatter.pharPath": "%APPDATA%\Composer\vendor\friendsofphp\php-cs-fixer\php-cs-fixer",
And the phpformatter.logging shows in the ">Developer: Toggle Developer Tools" not debug console.
Here are the couple issues I experienced, in case anyone else has similar troubles:
PHPFormatter: Could not open input file:
: I was using my homepath, ~
, in the pharPath
. I replaced this with the full path, and this error went away.
The "--level" option does not exist.
: Changed arguments
to ["--rules=@PSR2"]
Everything works great now, thanks!
In addition to aforementioned changes to --level
, I also needed to get rid of php
in php php-cs-fixer fix
command, since it is now a standalone file and not a .phar
one. My solution was "phpformatter.phpPath": "nohup"
. The resulting command in colsole now looks like this and works: "nohup" "php-cs-fixer" fix "/tmp/phpfmt-17064pZjqlYL7HmPF.tmp"
.
Hope this helps someone.
this title, i like... u're not alone
Finally got it working.
Steps
"phpformatter.arguments": [],
"phpformatter.pharPath" : "/Users/Sarav/php-cs-fixer-v2.phar"
Thats it! Now your code will get formatted.
Cheers!
@Sarav-S Thank you so much, I was so stressed for hours! looking for the solution in many sites, but finally your solution worked for me! :D
@fofosud Glad I could help :)
This is the reason this language is seriously fucked up! Something so straight forward like a formatter is stalling me for the whole day! I was trying to tweak something done by another developer, the code looks like shit paste! This is so painful!
For me the fix was "phpformatter.arguments": [] inside settings.json There must be some bug in the settings
Installed via homebrew. Here are the options I added in settings.json
for those with a similar env.
{
"phpformatter.composer": false,
"phpformatter.pharPath": "/usr/local/bin/php-cs-fixer",
"phpformatter.phpPath": "/usr/local/bin/php",
"phpformatter.arguments": [],
}
The phpformatter.arguments
option is an undocumented fix (as mentioned above, thanks @dean-me).
@Sarav-S you are a real hero - thank you!
@Sarav-S good job!
"phpformatter.arguments": []
MUST BE DOCUMENTED AS A MUST.
It's ridiculous for someone who have been coding for years to spend half hour setting up configs only to find that the reason a plugin cannot work is because one setting that is not even needed is mandatory
"phpformatter.arguments": [] MUST BE DOCUMENTED AS A MUST. Still not documented, I spent hours trying to get this working.
"phpformatter.arguments": [] did the trick 😢
I thought I was pretty competent, but I've spent an hour now. The command "phpformatter.fix" can't be run from the VS Code command line. The settings register, so VS Code must somehow be aware of PHP Formatter. The .phar archive is super duper in the right place, mapped in the settings, PHP is globally accessible. The keyboard bindings are pasted into the right file, but the shortcuts don't work. The documentation doesn't seem to discuss any of this.
It seems I have to go back to some external PHP formatter and copy/paste entire files in and out. I'm utterly lost with this plugin, nothing works, and I've done about 20 sanity checks now, I'm following every instruction to the letter. Is it this hard for anyone else?