Skip to content

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

shell
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

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 the Program field and the path to the NodeJS executable in the Environment field): JS file watcher configuration

  • SCSS: Add another watcher with the following settings (adjust the path to prettier in the Program field and the path to the NodeJS executable in the Environment field): scss file watcher configuration

    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 apply prettier to partial SCSS files (files whose names start with _)