PhpStorm
PhpStorm can be configured to automatically format the code for you on save.
PhpStorm configurator
Check out PhpStorm configurator, it automates configuring the file watchers.
For Vagrant installations (pre-commit hook)
Starting with v6.0 XalokNext also offers a script to setup php-cs-fixer as a pre-commit hook.
Run this on your computer (not in vagrant ssh
):
vendor/wfcms/standard/Wf/Bundle/CmsBaseAdminBundle/Resources/bin/git-hooks/pre-commit.sh
Make sure you have PHP installed (>7.4).
For PHP: php-cs-fixer
- Install php-cs-fixer according to the instructions at https://cs.symfony.com/#installation.
- Add a File Watcher (https://www.jetbrains.com/help/phpstorm/using-file-watchers.html#ws_creating_file_watchers) with the following configuration (adjust the path in the
Program
field according to where you installed php-cs-fixer in the step above):
For JavaScript/SCSS: prettier
install prettier (Note: prettier requires NodeJS to be at version 10.13.0 or later):
npm install --global prettier
JS: Add a File Watcher (https://www.jetbrains.com/help/phpstorm/using-file-watchers.html#ws_creating_file_watchers) with the following configuration (adjust the path to
prettier
in theProgram
field and the path to the NodeJS executable in theEnvironment
field):SCSS: Add another watcher with the following settings (adjust the path to
prettier
in theProgram
field and the path to the NodeJS executable in theEnvironment
field):Note: The SCSS configuration is very similar to the one for JS, the big difference is the presence of
COMPILE_PARTIAL=true
in the environment. This tells PhpStorm to also applyprettier
to partial SCSS files (files whose names start with_
)