6
votes

I am running phpStorm 7.1.3 version on Windows 7 and I have done everything accordingly to install composer and then phpunit. Now I have it in vendors directory. But every time I run my program which is a simple Yii application I get the same error.

PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Cannot create phar 'C:/wamp/www/myproject/vendor/bin/phpunit', file extension (or combination) not recognised or the directory does not exist' in C:\Users\myUser\AppData\Local\Temp\ide-phpunit.php:177

Please help, I am stuck here already two days and cant get this working, almost changed and reinstalled everything but is not helping.

I didn't use pear, I downloaded everything through the phpStorm. I downloaded composer, and after that through phpStorm composer I downloaded phpUnit 3.7.37.

Here is the screenshot of my settings for composer

enter image description here

Here is the content of my composer.json

{
    "require": {
        "phpunit/phpunit": "3.7.37"
    }
}

Here is the screenshot of my settings for PHPunit enter image description here

4
1) What PHPUnit do you use (what installation -- PEAR/Composer/PHAR)? 2) What PHPUnit version it is? 3) Screenshot of "Settings | PHP | PHPUnit" please - LazyOne
Ok I got everything you asked,,,, if there is anything else please let me know - user3600252

4 Answers

14
votes

On your 2nd screenshot (PHPUnit settings):

  • Why did you choose PHAR option if you are using COMPOSER?
  • Why did you point to .../bin/phpunit (even if you choose 3rd option .. you should point it to a PHAR file then)?

Therefore:

  • For composer installations you should use 2nd ("Use custom loader") option.
  • The edit box -- you should point it to your autoloader script (yes -- composer autoloader script).

Related (similar issue): https://stackoverflow.com/a/17316104/783119

3
votes

If you are not using composer, but the 'Path to phpunit.phar' option and still receive this error, just make sure the path you specify ends with a .phar (usually ends with phpunit.phar) I was seeing this same error but because I had the path pointing to my command-line alias, not the actual .phar file, it gets hung up on the improper extension and bails.

0
votes

I was trying to run phpUnit on zend framework 1.12.9 and had the same problem - solved it by changing path to phpunit.phar to use custom loader. Then You have to point it to the generated autoload.php by composer.

In my case that was

C:\wamp\www\phpu3\vendor\autoload.php

Later, the important thing to do was to point the bootstrap file from tests.

0
votes

When you download the phpunit.phar file using the wget command, following the instruction on the getting started manual - https://phpunit.de/getting-started/phpunit-4.html the "phar" extension is being removed, and PHPSTORM has issues to interrupt this file. I've changed the extension:

mv phpunit phpunit.phar

make sure you update the path to phpunit.phar file in the IDE setting accordingly