1

I have a very specific configuration that I have to hold until I can start moving feature from my old PHP 5 application to somewhere else.

I'm trying to tie my testing environment with PhpStorm but I cant figure it out. Since I'm not using Composer, I have to specify phpunit.phar path (which is /usr/local/bin/phpunit - a symlink to /usr/local/bin/phpunit.phar). I keep having this error.

PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Cannot create phar '/usr/local/bin/phpunit', file extension (or combination) not recognised or the directory does not exist' in /opt/.phpstorm_helpers/phpunit.php:181

Stack trace:

#0 /opt/.phpstorm_helpers/phpunit.php(181): Phar->__construct('/usr/local/bin/...')

#1 /opt/.phpstorm_helpers/phpunit.php(250): IDE_PHPUnit_Loader::init()

#2 {main} thrown in /opt/.phpstorm_helpers/phpunit.php on line 181

The setup on my Docker is PHP 5.5.9 with PHPUnit 4.8.9

My remote Docker PHP interpreter works in PhpStorm, and my PHPUnit works when I run test in bash (using docker exec phpunit) - so it seems that the pieces are working, mostly the glue doesn't work.

Here are my settings phpunit_framework_settings

4
  • What it has to do with WebStorm? WebStorm does not support PHP. Commented May 30, 2018 at 20:39
  • totally right, just corrected my typo Commented May 31, 2018 at 12:13
  • Please double check that /usr/local/bin/phpunit.phar is actually there in the container. Commented Jun 1, 2018 at 11:17
  • root@6649373c4111:/usr/local/bin# ls here is my ls output composer phpunit phpunit.phar set_tz Commented Jun 1, 2018 at 13:28

1 Answer 1

2

I just ran into this problem with composer and the issue is you need to set up a PHPUnit interpreter in PHPStorm with the autoload.php file.

  • Open Settings > Languages & Frameworks > PHP > Test Frameworks
  • Click the Plus + icon to add a Remote Interpreter
  • Select the CLI interpreter previously defined and use existing path mappings
  • Select Use Composer Autoloader
  • Path to script should be /path/to/vendor/autoload.php
  • Check off Default configuration file and set it to /path/to/phpunit.xml

I also needed to have the following section in my docker-compose.yml:

services:
  my-api:
    # Other contents omitted
    environment:
      - PHP_IDE_CONFIG=serverName=my-api.company.com

Where my-api.company.com is the server definition name from Settings > Languages & Frameworks > PHP > Servers

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.