phpStorm failed to run Codeception remote using Docker

I am trying to debug a Codeception test but I am unable since it fails with the following error:

[docker://drm-docker_client-apache:latest/]:php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=host.docker.internal /opt/.phpstorm_helpers/codeception.php run --report -o "reporters: report: PhpStorm_Codeception_ReportPrinter" --no-ansi --no-interaction -c /var/www/drm-client/codeception.yml tests/api/ClientCest.php

Could not open input file: /opt/.phpstorm_helpers/codeception.php

Process finished with exit code 1

Here is how I have setup the Test Framework:

A `docker container ls` will shown the phpstorm_helpers container created but not running:

λ docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f69142284830 e06ebb619315 "/bin/sh" About a minute ago Created phpstorm_helpers_PS-191.7479.51
5d0ed558c02d docker_client-apache "docker-php-entrypoi…" 2 minutes ago Up 2 minutes 0.0.0.0:8004->80/tcp client
340a923625b7 mysql/mysql-server:5.7 "/entrypoint.sh mysq…" 2 minutes ago Up 2 minutes (healthy) 0.0.0.0:3306->3306/tcp, 33060/tcp mysql

What I am missing here?

1
7 comments

We had a similar report recently, please check if following my advices posted here helps:

https://youtrack.jetbrains.com/issue/WI-46094#focus=streamItem-27-3403979.0-0

0

@Eugene apparently this issue is fixed on the latest phpStorm 2019.2 since it's gone now. However I am getting the following:

 An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddr 
esses: getaddrinfo failed: No address associated with hostname

My setup for Codeception looks as follow:

And this is the content of the xdebug.ini file:

zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_host=host.docker.internal
xdebug.remote_port=9000

What I am missing here? Is there any other config I have to do at phpStorm level?

 

1

Anyone find a solution? I have the same problem with the last version of PHPStorm. I am using the selenium/standalone-chrome-debug:latest image.

Versions:

  • PHPStorm: 2021.1.3
  • Docker: 2.5.0.1
  • PHP: 7.2.34
  • Codeception: 2.1.3

Configurations:

Docker

Server:

Interpreter:

Run/Debug:

 

Error on run a suite:

[docker://testes_eproc_workspace:latest/]:php /opt/.phpstorm_helpers/codeception.php run --report -o "reporters: report: PhpStorm_Codeception_ReportPrinter" --no-interaction core.acceptance -c /usr/src/myapp/codeception.yml .
Testing started at 14:19 ...

Warning: require_once(/usr/src/myapp/vendor/bin/autoload.php): failed to open stream: No such file or directory in /opt/.phpstorm_helpers/codeception.php on line 30

Call Stack:
0.0004 430880 1. {main}() /opt/.phpstorm_helpers/codeception.php:0


Fatal error: require_once(): Failed opening required '/usr/src/myapp/vendor/bin/autoload.php' (include_path='.:/usr/local/lib/php') in /opt/.phpstorm_helpers/codeception.php on line 30

Call Stack:
0.0004 430880 1. {main}() /opt/.phpstorm_helpers/codeception.php:0

Process finished with exit code 255

Am I mistake something?  There are any aditional configuration?

 

 

0

Mstrey, it complains that the file is not there, which probably means that the volumes mappings are either wrong or absent.
Could you please also share a screenshot of Settings | PHP?

reynierpm, I must have missed your comment, sorry. You probably got it sorted out a while ago, but in general, this error means that the Docker network the container runs in doesn't have the other services attached, probably because you had docker-compose run rather than docker-compose exec mode used.

0

Eugene Morozov this is my settings | PHP.

this is my docker-compose.yml:

version: "3.7"
services:

workspace:
network_mode: host
build:
context: .docker/workspace
dockerfile: Dockerfile
args:
PHP_VERSION: 7.2
XDEBUG_VERSION: 2.9.4
COMPOSER_VERSION: 2.0.8
HTTP_PROXY: ${http_proxy}
HTTPS_PROXY: ${http_proxy}
NO_PROXY: ${no_proxy}
restart: always
entrypoint: "tail -f /dev/null"
volumes:
- .:/usr/src/myapp
environment:
XDEBUG_CONFIG: remote_host=host.docker.internal

selenium-chrome-standalone:
image: selenium/standalone-chrome-debug:latest
ports:
- ${SELENIUM_HOST_PORT}:4444
- ${SELENIUM_HOST_VNC_PORT}:5900
volumes:
- /dev/shm:/dev/shm
environment:
- VNC_NO_PASSWORD=1

networks:
backend:
driver: bridge

 

Any suggestion?

0

Eugene Morozov

I'v tried another aproach. I create a new docker configuration:

And then a new interpreter with this configuration:

Finaly I change the interpreter in my Run/Debug:

but the error changed:

Codeception\Exception\ConnectionException : Can't connect to Webdriver at http://localhost:4444/wd/hub. Please make sure that Selenium Server or PhantomJS is running.
/opt/project/vendor/symfony/event-dispatcher/EventDispatcher.php:264
/opt/project/vendor/symfony/event-dispatcher/EventDispatcher.php:239
/opt/project/vendor/symfony/event-dispatcher/EventDispatcher.php:73
/opt/.phpstorm_helpers/codeception.php:51

 

despite that, the tests are running without problem directly inside de docker container:

 

 

0

I finally solved the mistery!!

1) In the Test Framework configuration the path to codeception need to be the full path /usr/src/myapp/vendor/codeception/codeception/codecept. PHPStorm canot support the alias /usr/src/myapp/vendor/bin/codecept

2) In the .env file we never can use localhost or 127.0.0.1. all references need to be to host.docker.internal.

Now all integration between PHPStorm and docker are sucessfully running

 

Eugene Morozov tks for your help.

7

Please sign in to leave a comment.