Open hkirsman opened 3 months ago
I initially tested with this script that we would have put under vendor/bin/:
#!/bin/bash
# Run PHP_CodeSniffer inside Docker container using the PHP 8.2 CLI image.
# The container will automatically be removed after execution (--rm).
# Mount the current working directory ($(pwd)) to the /app directory inside
# the container (-v $(pwd):/app).
# Set the working directory inside the container to /app (-w /app).
# Execute the PHP CodeSniffer command (./vendor/bin/phpcs) with the WunderAll
# standard inside the container.
# Pass any additional arguments ($*) from the script to the phpcs command.
docker run -i --rm -v $(pwd):/app -w /app php:8.2-cli ./vendor/bin/phpcs --standard=WunderAll $*
Then we can point to the script from IDE eg:
Result in the vscode:
Plugin used: https://marketplace.visualstudio.com/items?itemName=shevaua.phpcs
But why spin up yet another container, we already have Lando or DDEV running? Maybe only because we would create scanner images that we could use anywhere?
Another solution that would re-use Lando or DDEV would be to expose the phpcs (and other tools) eg lando phpcs
or ddev phpcs
.
How to integrate code checks into Visual Studio Code and PhpStorm?