Skip to content

Instantly share code, notes, and snippets.

@abedcodes
Last active April 14, 2025 19:17
Show Gist options
  • Save abedcodes/b95b435b5cb3df13acbf1016b447c13a to your computer and use it in GitHub Desktop.
Save abedcodes/b95b435b5cb3df13acbf1016b447c13a to your computer and use it in GitHub Desktop.
"php cs fixer" vscode extension setup

If you have installed "php cs fixer" vscode extension, the following will make it work on saving your php file

extension link: https://marketplace.visualstudio.com/items/?itemName=junstyle.php-cs-fixer

steps:

1- install phpcsfixer as a global composer package

composer global require friendsofphp/php-cs-fixer --dev

2- add this to your settings.json config object:

"[php]": {
    "editor.defaultFormatter": "junstyle.php-cs-fixer"
},
"php-cs-fixer.executablePath": "/home/YOURUSERNAME/.config/composer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer",
"php-cs-fixer.ignorePHPVersion": true,
"php-cs-fixer.onsave": true,

[ ! ] currently this extension does not support php8.4 so i had to ignorePHPVersion, don't know this format code badly in some cases?

[ ! ] set YOURUSERNAME for the executablePath to your system's username

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment