2
votes

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

1
What it has to do with WebStorm? WebStorm does not support PHP. - LazyOne
totally right, just corrected my typo - MastaJeet
Please double check that /usr/local/bin/phpunit.phar is actually there in the container. - Eugene Morozov
root@6649373c4111:/usr/local/bin# ls here is my ls output composer phpunit phpunit.phar set_tz - MastaJeet

1 Answers

1
votes

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