Question: I have an External Tools entry `php-cs-fixer` and I want run it **before** commit. I found only **after**, but why after? I need before.

I want after work with file, commit it and don't worry about code style, I want to know that my PhpStorm run external tools `php-cs-fixer` before committed file.

[![enter image description here](https://i.stack.imgur.com/kYUC7.jpg)](https://i.stack.imgur.com/kYUC7.jpg)

How to add run external tools before commit ?

Answer: 
There is no such built-in functionality.

<https://youtrack.jetbrains.com/issue/IDEA-111943> -- watch this ticket (star/vote/comment) to get notification on any progress.

---

In addition to `pre-commit` git hooks .. you may try using File Watcher functionality so it automatically runs every time you save the file (some people are using such approach).

* General info on File Watchers: <https://confluence.jetbrains.com/display/PhpStorm/File+Watchers+in+PhpStorm>
* [PHP CS Fixer File Watcher causes File Cache Conflict in PHPStorm](https://stackoverflow.com/q/44073562/783119) (example usage)
Checking PHP Coding Standards before commit

`package.json`

```
{
  "devDependencies": {
    "pre-commit": "^1.2.2"
  },
  "scripts": {
    "check-cs": "php ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --dry-run --stop-on-violation --using-cache=no",
    "fix-cs": "php ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no && exit 0"
  },
  "pre-commit": [
    "check-cs"
  ]
}

```

Install Node.js and npm

* For Ubuntu

```bash
sudo apt update
sudo apt install nodejs npm

```

* For Windows

```bash
npm install -g npm

```

Check the installed version

```bash
node -v
npm -v

```

`Output:`

```
v12.22.9
8.5.1

```

Install a package

```bash
npm install

```

[![enter image description here](https://i.stack.imgur.com/BoGvi.png)](https://i.stack.imgur.com/BoGvi.png)