Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running PHPUnit in Intellij with docker remote interpreter from docker-compose expects project in "/opt/project"

I have a PHP symfony project loaded in IntelliJ (2019.3.2, Build #IU-193.6015.39) with the following structure (left out irrelevant files like README, etc):

<project_root>
+- src/
+- tests/
+- vendor/
|  +- autoload.php    
+- .env
+- composer.json
+- composer.lock
+- docker-compose.yml
+- Dockerfile
+- phpunit.xml
+- phpunit-custom.xml

The project interpreter is set to use remote docker (Docker for Mac) by docker-compose and IntelliJ detects the interpreter and debugger correctly: enter image description here

docker-compose.yml has the following structure:

version: "2"

services:
    app:
        build: .
        env_file:
            - ./.env
        ports:
            - 8888:80
        volumes:
            - ./:/var/www/
            - .docker/app-dev/nginx/fastcgi-timeouts.conf:/etc/nginx/fastcgi-timeouts.conf
            - .docker/app-dev/php/conf.d/00_opcache.ini:/etc/php/conf.d/00_opcache.ini
            - .docker/app-dev/php/conf.d/30_xdebug.ini:/etc/php/conf.d/30_xdebug.ini
            - .docker/app-dev/php/php-fpm-settings.conf:/etc/php/php-fpm-settings.conf

    db:
        image: mysql:5.6
        environment:
            MYSQL_DATABASE: project_database
            MYSQL_USER: user
            MYSQL_PASSWORD: password
            MYSQL_ROOT_PASSWORD: master_password
        ports:
            - 3306:3306
        volumes:
            - mysql-data:/var/lib/mysql:delegated
            - .docker/db/mysqld.cnf:/etc/mysql/conf.d/mysqld.cnf
            - .docker/db/000-structure.sql:/docker-entrypoint-initdb.d/000-structure.sql
            - .docker/db/001-data.sql:/docker-entrypoint-initdb.d/001-data.sql
            - .docker/db/002-test-data.sql:/docker-entrypoint-initdb.d/002-test-data.sql

volumes:
    mysql-data:

So the project is mounted into the container's /var/www. After spinning up the project with docker-compose up -d it is accessible on http://localhost:8888 as expected. But running the unit-tests through IntelliJ does not work as the resulting command expects the configuration in /opt/project folder of the container:

[docker-compose://[/Users/me/projects/symfony_with_db/docker-compose.yml]:app/]:php /opt/.phpstorm_helpers/phpunit.php --configuration /opt/project/phpunit-custom.xml
Could not read "/opt/project/phpunit-custom.xml".

Process finished with exit code 1

Whereas the path to the configuration-file has to be provided as an absolute path in the UI. enter image description here

Entering the project-relative path does not work. enter image description here So there seems to be no way to tell IntelliJ to look into the path, where the project is actually mounted.

like image 809
fragmentedreality Avatar asked Nov 03 '25 21:11

fragmentedreality


1 Answers

I have a similar issue and I could't find any option in Intellij settings, so I need to manually change paths in .idea directory. Try search for /opt/project inside .idea directory and replace it with /var/www.

In my case, this issue was caused by the Python plugin in my Intellij Ultimate 2019.3

like image 93
Radek Avatar answered Nov 06 '25 12:11

Radek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!