Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phpunit run problems in phpstorm, Cannot create phar

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

like image 720
user3600252 Avatar asked May 03 '14 23:05

user3600252


2 Answers

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

like image 96
LazyOne Avatar answered Sep 28 '22 06:09

LazyOne


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.

like image 34
Joey T Avatar answered Sep 28 '22 04:09

Joey T