Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update doc #2135

Open
fabienwnklr opened this issue Jan 20, 2023 · 2 comments
Open

Update doc #2135

fabienwnklr opened this issue Jan 20, 2023 · 2 comments

Comments

@fabienwnklr
Copy link

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
@czosel
Copy link
Collaborator

czosel commented Jan 22, 2023

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.

@fabienwnklr
Copy link
Author

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants