If you want to automatically fix the code style in
php-cs-fixer, create a configuration file inside your project folder, name it -
Then, copy paste this code:
As you can see, there is a list of rules like:
list_syntax, etc. You can add your own rules or use the predefined ones, if you want more information - take a look here.
Next, go to:
File -> Settings -> Tools -> External Tools
And fill these lines:
--verbose --config=/path-to-config-file/.php_cs.dist fix "$FileDir$/$FileName$"
- Working directory:
One more thing, you need to add key binding for a new command. Go to
File -> Settings -> Keymap: (Search by the name of your external tool). In my case, it's a
That's it; now you can use it.
Open any PHP file and use your key binding - it will fix your code according to your configuration.