Skip to content

Instantly share code, notes, and snippets.

@joemaller
Created October 2, 2023 01:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joemaller/dd8e5e92c8094afe015faafdade0ebfa to your computer and use it in GitHub Desktop.
Save joemaller/dd8e5e92c8094afe015faafdade0ebfa to your computer and use it in GitHub Desktop.

How to run phpcs on WordPress-Develop files without installing PHP

I've been running all my dev projects via Docker to avoid the pitfalls of installing server software on my computer. This also lets me jump between macheines very easily since everything I need is wrapped up in dockerfiles, docker-compose files or package.json scripts.

WordPress development doesn't work like that. The default development environment expects PHP to be installed and will try to run PHPCS validation checks from a local instance of PHP.

Use Composer's Docker image

The official Composer Docker image is extremely versatile. It can run arbitrary shell commands if the passed argument isn't a Composer keyword.

To run the same phpcs coding-stanards checks WordPress runs from GitHub Actions, do this:

docker run --rm -v $(pwd):/app composer /app/vendor/bin/phpcs -n --report-full
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment