[英]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. 我在Windows 7上运行phpStorm 7.1.3版本,我已经做了相应的事情来安装composer然后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. 但每次我运行我的程序,这是一个简单的Yii应用程序,我得到相同的错误。
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 PHP致命错误:未捕获异常'UnexpectedValueException',消息'无法创建phar'C:/ wamp / www / myproject / vendor / bin / phpunit',文件扩展名(或组合)无法识别或目录不存在'在C中: \\用户\\ MYUSER \\应用程序数据\\本地的\\ 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. 我没有使用pear,我通过phpStorm下载了所有内容。 I downloaded composer, and after that through phpStorm composer I downloaded phpUnit 3.7.37. 我下载了作曲家,然后通过phpStorm作曲家我下载了phpUnit 3.7.37。
Here is the screenshot of my settings for composer 这是我的作曲家设置的屏幕截图
Here is the content of my composer.json 这是我的composer.json的内容
{
"require": {
"phpunit/phpunit": "3.7.37"
}
}
Here is the screenshot of my settings for PHPunit 这是我的PHPunit设置的屏幕截图
On your 2nd screenshot (PHPUnit settings): 在您的第二个屏幕截图(PHPUnit设置):
.../bin/phpunit
(even if you choose 3rd option .. you should point it to a PHAR file then)? 为什么你指向.../bin/phpunit
(即使你选择第三个选项..你应该把它指向一个PHAR文件)? Therefore: 因此:
Related (similar issue): https://stackoverflow.com/a/17316104/783119 相关(类似问题): https : //stackoverflow.com/a/17316104/783119
如果你没有使用作曲家,但是'路径到phpunit.phar'选项并仍然收到此错误,只需确保你指定的路径以.phar结尾(通常以phpunit.phar结尾)我看到同样的错误但是因为我的路径指向我的命令行别名,而不是实际的.phar文件,它会挂在不正确的扩展和保释上。
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. 我试图在zend框架1.12.9上运行phpUnit并遇到同样的问题 - 通过改变phpunit.phar的路径来使用自定义加载器来解决它。 Then You have to point it to the generated autoload.php by composer. 然后你必须通过作曲家将它指向生成的autoload.php。
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. 后来,重要的是要从测试中指出bootstrap文件。
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. 当您使用wget
命令下载phpunit.phar
文件时,请按照入门手册上的说明进行操作 - https://phpunit.de/getting-started/phpunit-4.html删除“phar”扩展名,并使用PHPSTORM有中断此文件的问题。 I've changed the extension: 我改变了扩展名:
mv phpunit phpunit.phar
make sure you update the path to phpunit.phar
file in the IDE setting accordingly 确保phpunit.phar
在IDE设置中更新phpunit.phar
文件的路径
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.