phpunit run problems in phpstorm, Cannot create phar

user3600252 picture user3600252 · May 4, 2014 · Viewed 9.3k times · Source

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

Answer

LazyOne picture LazyOne · May 4, 2014

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