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

Update doc

Open fabienwnklr opened this issue 3 years ago • 2 comments

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

fabienwnklr avatar Jan 20 '23 13:01 fabienwnklr

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.

czosel avatar Jan 22 '23 21:01 czosel

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.

sure, but if we don't use config file, doesn't work so add this in doc can bu use full :)

fabienwnklr avatar Jan 22 '23 22:01 fabienwnklr