简体   繁体   English

如何在PhpStorm 8的远程服务器上使用PHPUnit

[英]How to use PHPUnit on remote server with PhpStorm 8

I've got a php-fpm 5.3.10 installation running on Ubuntu 12.04 on a remote server, and I'm trying to use PHPUnit from within PhpStorm 8 (as of yesterday). 我已经在远程服务器上的Ubuntu 12.04上运行了php-fpm 5.3.10安装,并且试图从PhpStorm 8(截至昨天)中使用PHPUnit。 I don't have a local php installation. 我没有本地php安装。

I have installed PHPUnit on my server and can use it via the commandline. 我已经在服务器上安装了PHPUnit,并且可以通过命令行使用它。

I have (seemingly) successfully linked my PhpStorm to my remote server and remote interpreter, and configured the right deployment settings. 我(似乎)已成功将我的PhpStorm链接到我的远程服务器和远程解释器,并配置了正确的部署设置。

At first I had an issue where it would try to run my local paths remotely, but that issue has been sorted. 最初,我遇到了一个问题,它将尝试远程运行我的本地路径,但是已经解决了该问题。 However, I keep getting the error Cannot find PHPUnit in include path (.:/usr/share/php:/usr/local/bin) . 但是,我不断收到错误Cannot find PHPUnit in include path (.:/usr/share/php:/usr/local/bin) This is almost certainly a serverside error (PhpStorm also knows these include paths, it could be confusing them for local paths) as the paths change when I change my include path in my php.ini. 几乎可以肯定这是服务器端错误(PhpStorm也知道这些包含路径,这可能会使它们混淆为本地路径),因为当我在php.ini中更改包含路径时,路径会发生变化。

This is the same error it gives back if I don't install PHPUnit at all, so again it would seem this is a serverside issue. 如果我根本不安装PHPUnit,则会返回相同的错误,因此再次看起来这是服务器端问题。

I have tried installing PHPUnit through PEAR (which is deprecated and soon unsupported by PHPUnit but still mentioned in a lot of PhpStorm tutorials), through Composer (on the remote server, not in PhpStorm) and even just manually. 我尝试过通过PEAR(已弃用,PHPUnit很快不再支持,但在许多PhpStorm教程中仍然提到),通过Composer(在远程服务器上,而不是在PhpStorm中)安装PHPUnit,甚至只是手动安装。

The server accepted these installation methods just fine (the PEAR method seems to install an older version of PHPUnit, 1.0.x instead of the apparently available 4.0.x) but they all give the same issue. 服务器接受了这些安装方法就很好了(PEAR方法似乎安装了PHPUnit 1.0.x的较早版本,而不是显然可用的4.0.x),但是它们都给出了相同的问题。

If I manually place PHPUnit in my include path (I'm unsure what kind of files it wants there, though. a .phar? Source files?) it does seem to pick up something, but I get an XDebug error instead and it tells me it can't find the necessary PHPUnit files so I assume it is not the way to go (it shouldn't have to be). 如果我手动将PHPUnit放在我的包含路径中(虽然我不确定它想要的文件类型是什么。.phar?源文件?),它的确似乎拾取了某些东西,但是却出现了XDebug错误,并告诉我我找不到所需的PHPUnit文件,所以我认为这不是可行的方法(不必这样)。

At this point I'm starting to run out of ideas and none of the Stackoverflow responses to similar issues or PhpStorm/PHPUnit documentations seem to be able to help me. 在这一点上,我的想法已经用尽,而且对于类似问题或PhpStorm / PHPUnit文档的Stackoverflow响应似乎都无法帮助我。

Edit 1: Included picture of settings, as requested. 编辑1:根据要求包含设置的图片。

(can't post images yet, not enough rep) settings (尚无法发布图片,代表数量不足) 设置

Other than that it's probably worth noting I'm using a mounted folder for my deployment, which just refers to the filesystem of my server (it's in my local network) 除此之外,可能值得注意的是我正在使用已安装的文件夹进行部署,该文件夹仅指服务器的文件系统(位于我的本地网络中)

Edit 2: Changed deployment to SFTP as suggested and updated my mappings, as PhpStorm is able to successfully validate my remote environment everything seems to be in order there. 编辑2:根据建议将部署更改为SFTP,并更新了我的映射,因为PhpStorm能够成功验证我的远程环境,一切似乎都井井有条。

After reinstalling PHPUnit via Composer and selecting the autoloader in my PHPUnit settings it was still giving the error about the include path (it shouldn't do when the autoloader is used, should it?) so I changed the include path to point to /usr/share/php/Composer/vendor/phpunit (and the two directories above it, for good measure). 通过Composer重新安装PHPUnit并在我的PHPUnit设置中选择自动加载器后,它仍然给出有关包含路径的错误(使用自动加载器时不应该这样做,应该吗?),因此我将包含路径更改为指向/usr/share/php/Composer/vendor/phpunit (以及上面的两个目录, /usr/share/php/Composer/vendor/phpunit )。

It was still giving the error, however in the error it says it cannot find PHPUnit in the include path, while the installation is in a directory called phpunit (all lowercase). 它仍在给出错误,但是在错误中说它在安装路径中名为phpunit的目录(全部小写)中找不到包含路径中的PHPUnit。 After changing the directory name to PHPUnit, it is no longer giving the include path error, but en XDebug error instead : Warning: include(/usr/share/php/Composer/vendor/phpunit/phpunit/PHPUnit/TextUI/ResultPrinter.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /usr/share/php/Composer/vendor/composer/ClassLoader.php on line <i>382</i> 将目录名称更改为PHPUnit后,不再提供包含路径错误,而是Warning: include(/usr/share/php/Composer/vendor/phpunit/phpunit/PHPUnit/TextUI/ResultPrinter.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /usr/share/php/Composer/vendor/composer/ClassLoader.php on line <i>382</i> XDebug错误: Warning: include(/usr/share/php/Composer/vendor/phpunit/phpunit/PHPUnit/TextUI/ResultPrinter.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /usr/share/php/Composer/vendor/composer/ClassLoader.php on line <i>382</i>

I'm unsure what this implies exactly, and I don't know whether the error is because I should not be changing the directory names (it seems as if that should not be necessary), because I haven't changed enough of them (other directories are likely still lowercase) or because these files should simply not be in the include path (composer should be managing my dependencies, shouldn't it?). 我不确定这到底意味着什么,而且我不知道错误是否是因为我不应该更改目录名(似乎应该没有必要),因为我没有对它们进行足够的更改(其他目录可能仍然是小写),或者因为这些文件根本不应该包含在include路径中(编写者应该管理我的依赖关系,不是吗?)。

In some cases, this can be resolved extremely easily. 在某些情况下,这可以非常轻松地解决。 PHPStorm looks for the folder PHPUnit in the include path(s), but I've found this is case sensitive! PHPStorm在包含路径中查找文件夹PHPUnit,但是我发现这区分大小写! Installing through composer will install PHPUnit in a folder called /vendor/phpunit/phpunit/phpunit, this is all lower case. 通过composer进行安装会将PHPUnit安装在名为/ vendor / phpunit / phpunit / phpunit的文件夹中,全部为小写。 This means that PHPStorm will not be able to find the folder unless you change the folder name to 'PHPUnit'. 这意味着除非将文件夹名称更改为“ PHPUnit”,否则PHPStorm将无法找到该文件夹​​。 The include path should therefore be: /usr/share/php/composer/vendor/phpunit/phpunit and in that folder, there should be another folder called 'PHPUnit' (case sensitive!). 因此,include路径应为:/ usr / share / php / composer / vendor / phpunit / phpunit,在该文件夹中,应该还有一个名为“ PHPUnit”的文件夹(区分大小写!)。 I'm sure this isn't the prefect solution, but it works. 我确定这不是完美的解决方案,但是可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM