phpcs: Could not open input file

When I open my project, I get a toast message about PHP_CodeSniffer not being able to find input file. I'm unable to figure out the exact settings I need to use.

My project root has a phpcs.xml file with our coding standard, that's consumed by some GitLab pipeline. The application runs inside a Docker container and all the code is in a volume. Potentially, I have three ways to run phpcs:

  1. Preferred option would be a dedicated phpcs container. In a terminal, I can do this just fine:
    docker run -it -v "$(pwd)":/code phpcs --report=full
  2. I also have a local PHP interpreter in host machine (Kubuntu) with a global PHP_CodeSniffer installation. In a terminal:
    phpcs --report=full
  3. And PHP_CodeSniffer is also available inside the application container, as DEV dependency for some third-party package, although we'll probably remove it at some point:
    docker exec -it app-container-name vendor/bin/phpcs --report=full
    Edit: this one doesn't actually work, it targets an invalid PHP version.

I'm lost in PHP_CodeSniffer settings dialogue. There's a side pane with three interpreters (two of them come from the CLI Interpreters section, where I've defined my app container and my local binary; the other one is called "System PHP" and I don't know where it comes from), I've been trying several combinations and I never make it work. I can't even understand how to let PhpStorm know which of the interpreters to use.


I think I fixed it!

First I did some PHP interpreter cleanup at Settings/ PHP (remove a duplicate one and give them betters names), and I added a new one for the Docker image where PHP_CodeSniffer is installed (after all, that container has PHP available too for obvious reasons). Then I went to Settings/ PHP/ Quality tools, I removed all the configurations and I created a new item using the new PHP interpreter. I had to enter the full path for all commands* but, once done that, it finally passed validation and PhpStorm is reporting style violations now.


docker run -it -v "$(pwd)":/code  which phpcs
docker run -it -v "$(pwd)":/code  which phpcbf




Can you specify where you entered the full command path? For the life of me, I can't get PHPCBF to work within the docker php container because even if you set a standard after adding the path to the ruleset, the path for the command has mixed Windows/Linux path entries which renders the command useless.


The commands I shared (I realise now that it may not be too clear) are something I run once to find the paths. One I have them (e.g. “/app/vendor/bin/phpcs”) I enter them as follows.

I'm using the “” third-party image. I go to Settings/ PHP/ PHP_CodeSniffer/ Configuration. I pick a setting in the “…” button to open another dialogue and paths go into “PHP_CodeSniffer path” and “Path to phpcbf”.

In any case, there is no Windows involved in my setup. 🤷


Please sign in to leave a comment.