August 24, 2023 ~1 minute minutes read Admin

Prettier when it works

Prettier is a great code beautifier for PHP, once you get it to work.


On Arch Linux, PHP 8.2

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

usage: prettier test.php

But all I could get was

[error] No parser could be inferred for file "test.php"

After a lot of fiddling and swearing, I solved it by creating ~/.prettierrc

  "plugins": ["/usr/local/lib/node_modules/@prettier/plugin-php/src/index.js"]