How to use phpcs from docker-compose?

See original GitHub issue

I use wodby/drupal-php (docker4drupal), which have inside a phpcs docker-compose exec php phpcs --version

PHP_CodeSniffer version 3.3.2 (stable) by Squiz (http://www.squiz.net)

Can I use this in vscode?

I trying create exec file phpcs-vscobe

#!/bin/sh

docker-compose exec php phpcs "$@"

and have an error from phpcs-vscode:

the input device is not a TTY

I added to file export COMPOSE_INTERACTIVE_NO_CLI=1

and error changed to

phpcs: Unable to locate phpcs. Command failed: “/home/alexey/phpcs-vscode” --version Traceback (most recent call last): File “/usr/lib/python3.7/site-packages/dockerpty/pty.py”, line 334, in start self._hijack_tty(pumps) File “/usr/lib/python3.7/site-packages/dockerpty/pty.py”, line 367, in _hijack_tty read_ready, write_ready = io.select(read_pumps, write_streams, timeout=60) File “/usr/lib/python3.7/site-packages/dockerpty/io.py”, line 59, in select timeout, File “/usr/lib/python3.7/site-packages/dockerpty/io.py”, line 351, in fileno return self.from_stream.fileno() File “/usr/lib/python3.7/site-packages/dockerpty/io.py”, line 103, in fileno return self.fd.fileno() File “/usr/lib/python3.7/socket.py”, line 638, in fileno self._checkClosed() ValueError: I/O operation on closed file. During handling of the above exception, another exception occurred: Traceback (most recent call last): File “/usr/bin/docker-compose”, line 11, in <module> load_entry_point(‘docker-compose==1.23.2’, ‘console_scripts’, ‘docker-compose’)() File “/usr/lib/python3.7/site-packages/compose/cli/main.py”, line 71, in main command() File “/usr/lib/python3.7/site-packages/compose/cli/main.py”, line 127, in perform_command handler(command, command_options) File “/usr/lib/python3.7/site-packages/compose/cli/main.py”, line 535, in exec_command pty.start() File “/usr/lib/python3.7/site-packages/dockerpty/pty.py”, line 338, in start io.set_blocking(pump, flag) File “/usr/lib/python3.7/site-packages/dockerpty/io.py”, line 32, in set_blocking old_flag = fcntl.fcntl(fd, fcntl.F_GETFL) File “/usr/lib/python3.7/site-packages/dockerpty/io.py”, line 351, in fileno return self.from_stream.fileno() File “/usr/lib/python3.7/site-packages/dockerpty/io.py”, line 103, in fileno return self.fd.fileno() File “/usr/lib/python3.7/socket.py”, line 638, in fileno self._checkClosed() ValueError: I/O operation on closed file.

I don`t known that I can try else. I whuld be happy if we could solve this situation. 😃

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

2reactions
Idealiencommented, Mar 15, 2019

I tried same setup and the current result is a less verbose error, “phpcs: Cannot read property ‘toString’ of null”

1reaction
jgonyeacommented, May 31, 2019

The closest I could get was to create an executable bash wrapper at /usr/local/bin/phpcs with the following:

#!/bin/sh

 export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin

 docker run --rm --user $(id -u):$(id -g) --volume $(pwd):/project herloct/phpcs --standard=PSR2 $@

Then I’m able to run phpcs from the VSCode terminal. I still can’t get the GUI to recognize issues, however. I see the spinning loading icon that phpcs is attempting to parse the current PHP file as I edit it.

OS: Ubuntu 19.04 Docker version 19.03.0-beta5, build 4a18bf4

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker Compose: support PHP_CodeSniffer, PHP CS Fixer ...
1. Create the following docker-compose.yml · 2. Create remote interpreter based on this docker compose · 3. Create PHPCS config based on the...
Read more >
How to use php-cs-fixer in vscode with docker container for ...
So when using this, I create my settings per-folder like this: "simple-php-cs-fixer.executablePath": "/Users/me/code/myproject/docker-phpcs" ...
Read more >
PHP Code Sniffer with Docker - Medium
In this post I will tell about my experience running PHPCS in a Docker container. I will share my Docker file and the...
Read more >
Set up PHP QA tools and control them via make [Tutorial Part 5]
All code samples are publicly available in my Docker PHP Tutorial ... phpcs and phpcbf; phpstan; php-parallel-lint; composer-require-checker ...
Read more >
How to develop PHP inside a Docker Container using VS Code
Simply copy/pasting the .devcontainer and .vscode folders into my project? Since i use docker-compose, I could have a devcontainer service with ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found