plugin-php
plugin-php copied to clipboard
Update doc
Hey,
for use your (great) plugin, we need to use --parser=php on command line, i think it's good to add it on your doc :)
he's specified but not everywhere
yarn run prettier --parser=php path/to/file.php --write
# or
npm run prettier --parser=php path/to/file.php --write
and
prettier --parser=php path/to/file.php --write
Hi @fabienwnklr,
if you don't pass the parser argument prettier attempts to guess the correct parser (based on file extension I think). For me that works:
/tmp/prettier-php $ yarn add prettier @prettier/plugin-php
yarn add v1.22.19
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 8 new dependencies.
info Direct dependencies
├─ @prettier/[email protected]
└─ [email protected]
info All dependencies
├─ @prettier/[email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
Done in 3.30s.
/tmp/prettier-php $ vim test.php
/tmp/prettier-php $ yarn prettier test.php
yarn run v1.22.19
$ /tmp/prettier-php/node_modules/.bin/prettier test.php
<?php
if ("foo") {
echo "bar";
}
Done in 0.20s.
Hi @fabienwnklr,
if you don't pass the
parserargument prettier attempts to guess the correct parser (based on file extension I think). For me that works:/tmp/prettier-php $ yarn add prettier @prettier/plugin-php yarn add v1.22.19 info No lockfile found. [1/4] Resolving packages... [2/4] Fetching packages... [3/4] Linking dependencies... [4/4] Building fresh packages... success Saved lockfile. success Saved 8 new dependencies. info Direct dependencies ├─ @prettier/[email protected] └─ [email protected] info All dependencies ├─ @prettier/[email protected] ├─ [email protected] ├─ [email protected] ├─ [email protected] ├─ [email protected] ├─ [email protected] ├─ [email protected] └─ [email protected] Done in 3.30s. /tmp/prettier-php $ vim test.php /tmp/prettier-php $ yarn prettier test.php yarn run v1.22.19 $ /tmp/prettier-php/node_modules/.bin/prettier test.php <?php if ("foo") { echo "bar"; } Done in 0.20s.
sure, but if we don't use config file, doesn't work so add this in doc can bu use full :)