通过Phar自动完成的PhpStorm PhpUnit不起作用 [英] PhpStorm PhpUnit via phar autocomplete not working
问题描述
我有PHPStorm 8.0.1.
I have PHPStorm 8.0.1.
PHPUnit是通过PHAR归档文件安装的,例如:
PHPUnit is installed via PHAR archive like:
wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/bin/phpunit
PHPUnit通过cli起作用:
PHPUnit works via cli:
user@pc:/usr/bin$ cd ~
user@pc:~$ phpunit --version
PHPUnit 4.3.5 by Sebastian Bergmann.
我按照JetBrains网站 https://www.jetbrains.com/的说明进行操作phpstorm/webhelp/enabling-phpunit-support.html#d298258e897
I followed the instructions from JetBrains website https://www.jetbrains.com/phpstorm/webhelp/enabling-phpunit-support.html#d298258e897
在PHPStorm文件->设置"选项卡中,PHP/PHPUnit
单选按钮Path to phpunit.phar
已选中
并将值设置为/usr/bin/phpunit
In PHPStorm File->Settings tab PHP/PHPUnit
the radio button Path to phpunit.phar
is checked
and value is set to /usr/bin/phpunit
我有一个文件,其测试定义如下:
I have a file with a test defined like:
class MyTest extends PHPUnit_Framework_TestCase {
...
此时,PHPStorm标记为Undefined class PHPUnit_Framework_TestCase
At this point PHPStorm marks Undefined class PHPUnit_Framework_TestCase
我已经重新启动了PHPStorm和Computer,但是仍然遇到相同的问题.
I've restarted PHPStorm and Computer, but still have the same problem.
我还尝试添加/usr/bin
来包含路径(在项目视图中右键单击外部库,然后选择选项Configure PHP include paths
),但没有成功.
I've also tried adding /usr/bin
to include path (right click on external libraries in project view, and choose option Configure PHP include paths
) without success.
这是PHPStorm设置的配置,请选择PHP(如果需要):
Here's the config for PHPStorm Settings, tab PHP (if it matters):
PHP Language level: 5.5 (finally, generators, etc.)
Interpreter: PHP 5.5 (5.5.9-1ubuntu4.5)
Include path is empty
推荐答案
要使IDE索引PHAR存档,它必须具有.phar
扩展名(这是必需的).
In order to have PHAR archive indexed by IDE it has to have .phar
extension (that's a requirement).
最简单的解决方案是将phpunit.phar
放置在项目中的某个位置(通常是PROJECT_ROOT/vendor/
文件夹).
The easiest solution is to place phpunit.phar
somewhere in your project (usually it would be PROJECT_ROOT/vendor/
folder).
如果不需要本地副本(出于某种原因;尽管作曲家和其他类似工具(bower/npm/etc)主要用于将依赖项/程序包保留在本地),您可以使用符号链接:或者在本地创建指向该文件的符号链接(例如PROJECT_ROOT/phpunit.phar
-> /usr/bin/phpunit
)..或将完整副本(或此类符号链接)放置在单独文件夹中在磁盘上,然后通过PhpStorm的Settings | PHP | Include Paths
功能进行引用.
If having local copy is not desired (for whatever reason; although composer and other similar kind of tools (bower/npm/etc) are primarily aimed at keeping dependency stuff/packages locally), you may use symbolic links: either create a symbolic link to that file locally (e.g. PROJECT_ROOT/phpunit.phar
--> /usr/bin/phpunit
) .. or place a full copy (or such symbolic link) in separate folder somewhere on your disk and then reference it via PhpStorm's Settings | PHP | Include Paths
functionality.
这篇关于通过Phar自动完成的PhpStorm PhpUnit不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!