1

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). I don't have a local php installation.

I have installed PHPUnit on my server and can use it via the commandline.

I have (seemingly) successfully linked my PhpStorm to my remote server and remote interpreter, and configured the right deployment settings.

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). 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.

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.

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.

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.

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).

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.

Edit 1: Included picture of settings, as requested.

(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.

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).

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). 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>

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?).

8
  • 1) I assume that you have CORRECTLY set up Remote PHP Interpreter, right? 2) Screenshot of Settings | PHP | PHPUnit 3) Make sure that you have properly created Deployment entry of SFTP type and marked it as Default for this project -- IDE will use path mappings from it Commented Sep 18, 2014 at 9:15
  • I edited my question with additional info, all of my settings appear to be in order (at least to me) Commented Sep 18, 2014 at 9:33
  • 1) If you want to use ** Remote PHP Interpreter** (works over SSH) then you have to use SFTP deployment. 2) You are using "Load from include path". In such case you have to add path to PHPUnit installation in your include_path option in php.ini. NOTE: this will only work if your PHPUnit installation is composer based (tons of individual files). If installed via PEAR -- it is actually a PHAR. So better use either pure Composer way (and use autoloader option) or PHAR one. Commented Sep 18, 2014 at 9:39
  • I was unaware that SFTP was a requirement in this scenario, I also use the the mounted folder for my PhpStorm project files, so technically nothing ever needs deployment to anywhere outside of my project, is there any way to take advantage of that fact? Commented Sep 18, 2014 at 9:49
  • You may not need to use it to transfer files ... but it is definitely needed for path mappings. confluence.jetbrains.com/display/PhpStorm/… Commented Sep 18, 2014 at 9:52

1 Answer 1

1

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! Installing through composer will install PHPUnit in a folder called /vendor/phpunit/phpunit/phpunit, this is all lower case. This means that PHPStorm will not be able to find the folder unless you change the folder name to 'PHPUnit'. 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!). I'm sure this isn't the prefect solution, but it works.

Sign up to request clarification or add additional context in comments.

5 Comments

This is a colleague of mine, and he is the one that came up with this solution in the end. Thanks to @LazyOne for pointing us in the right direction concerning SFTP and such.
"but I've found this is case sensitive!" -- Don't really understand a surprise here. Linux IS a case-sensitive OS and uses case-sensitive file systems (while Windows is opposite). If you have installed PHPUnit via composer .. then using "autoloader" option (instead of "include paths") should be working fine and should bypass such moment from the beginning -- don't know why it did not worked for you.
Yes, we're aware this is a difference between Windows an Linux, however we expected PhpStorm to also be aware of this and know what kind of naming conventions PHPUnit uses. In the end we had to change directory names, this seems unconventional.
Why it should be aware of that? And why IDE is even mentioned here? It's PHP itself that is unable to find the file and not IDE. If IDE does not translate paths correctly (local<->remote) or something like that -- then yes, but otherwise -- it's all about PHP itself/configuration. BTW: Did you managed to figure out why "autoloader" option did not worked for you .. or you have stopped at current working solution?
might be safer to symlink to the folder, rather than move it altogether

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.