Search code examples
phpdockerphpstormphpcs

Configure CodeSniffer on PhpStorm using Docker


I am developing a project using PhpStorm and I am using Php 7.1 with Docker. I would like to integrate PHP code sniffer in PhpStorm.

In PhpStorm I go to Settings|Languages&Frameworks|PHP|CodeSniffer and I try to add a new configuration, I provide as PHP Code Sniffer (phpcs) path the path of a script with the following content:

#!/usr/bin/env bash
docker run --rm -ti --volume "$(pwd):/app:rw" -u $(id -u):$(id -g) prooph/php:7.1-cli php vendor/bin/phpcs "$@"

which just runs phpcs in my docker container.

When I click on Validate, PhpStorm gives me the following message:

The input device is not a TTY

The same script works perfectly when it's run from PhpStorm console.

Am I doing something wrong? Or what I am trying to do is just not supported?


Solution

  • You should run it without -t flag:

    #!/usr/bin/env bash
    docker run --rm -i --volume "$(pwd):/app:rw" -u $(id -u):$(id -g) prooph/php:7.1-cli php vendor/bin/phpcs "$@"
    

    -t allocates a pseudo-TTY, that's why it works on PhpStorm console.