Open heheda123123 opened 1 year ago
Are your PHP files in a Node project (with its own package.json
)? In that case, it might work to try npm install prettier @prettier/plugin-php
with no --global
option.
no, it's just a single php file
in a different computer, create a simple php file, still have this problem
Just ran into the same issue, also on a one-off project w/ no package.json
, but it's nothing to do w/ this package. It's related to a breaking change in prettier v3. More info here: https://github.com/prettier/plugin-php/issues/2215
I have worked around it by putting a .prettierrc.json
in $HOME
and explicitly adding plugins that way:
{
"plugins": [
"/usr/local/lib/node_modules/@prettier/plugin-php/src/index.js"
]
}
With this, prettier on the CLI and via emacs starts working again. (prettier searchs for configs up from the file being formatted, and – in my case – all of my code is in $HOME/src
. If you put your code elsewhere, you should adjust accordingly.)
(BTW Apparently global installs still can't handle short plugin names like @prettier/plugin-php
, so the full path is required.)
Thanks, glad to have this sorted out. This is excellent information. We should add this link to the readme if more people stumble upon the same problem.
little update - this is upstream issue:
when use format-all-buffer for any php file, it shows
in
*format-all-errors*
I already install the plugin