plugin-php icon indicating copy to clipboard operation
plugin-php copied to clipboard

[error] No files matching the pattern were found: "path/to/file.php".

Open Shamo84 opened this issue 2 years ago • 5 comments

so I installed this plugin globally with:

npm install --global prettier @prettier/plugin-php

but when I run prettier path/to/file.php --write

i get this error: [error] No files matching the pattern were found: "path/to/file.php".

Shamo84 avatar Dec 06 '22 13:12 Shamo84

Hi @Shamo84, I wasn't able to reproduce the issue:

$ npm install --global prettier @prettier/plugin-php


added 8 packages, and audited 9 packages in 5s

2 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
$ prettier foo.php
<?php

if (true) {
    echo "foo";
}
$ prettier foo.php --write
foo.php 7ms
$ cat foo.php 
<?php

if (true) {
    echo "foo";
}

Can the file path be resolved when you replace prettier with any other command, e.g. ls?

czosel avatar Dec 10 '22 12:12 czosel

I'm getting a similar message using the package as a devDependency with Yarn:

$ yarn run prettier path/to/file.php --write

# Output:
# [error] No parser could be inferred for file: path/to/file.php

dantemogrim avatar Dec 19 '22 15:12 dantemogrim

Same issue for me.

Tried with node 20.4.0 with either yarn 1.22.19 or npm 9.7.2 under macos Also tried with node 18.16.1 with either yarn 1.22.19 or nom 9.6.6 under alpine linux

fresh global install in all cases, the next call to prettier <file in current folder> results in No parser could be inferred for file

andrei-dascalu avatar Jul 09 '23 11:07 andrei-dascalu

Try use prettier 2.8.8 instead of 3.0

Nyholm avatar Jul 21 '23 22:07 Nyholm

Hi @Shamo84 , I ran into a similar issue, and if you use prettier 3, you need to explicitly enable the plugin by passing --plugin @prettier/plugin-php in the cli, or "plugins": ["@prettier/plugin-php"] in your prettier file.

See https://github.com/prettier/plugin-php/issues/2215#issuecomment-1684376930

jdeniau avatar Aug 31 '23 10:08 jdeniau