LoginSignup
4
3

More than 5 years have passed since last update.

Laravel + Homestead(Vagrant) + PhpStormでPHPUnit実行時に"Cannot find PHPUnit in include path (.:/usr/share/php)"が出る問題

Posted at

環境

  • Laravel 5.4
  • Homestead 6.1.0 (Vagrant経由で起動)
  • Windows10(Homesteadとの共有フォルダを作成してWindows上でソースを編集している)
  • PhpStorm 182.3911.43

やろうとした事

PhpStormからPHPUnitを実行したい
ただし、phpはローカルにはなく、リモート(Homestead)上のphpを実行する必要がある

現象

上記の環境で、PhpStormからPHPUnitを実行すると
Cannot find PHPUnit in include path (.:/usr/share/php) というエラーが発生する
image.png

解決方法

  1. Homesteadに接続し以下を実行する
composer install --dev
composer dumpautoload
  1. PhpStormの設定画面からテスト実行用のインタプリタを設定する

Ctrl + Alt + S で設定画面を開き、Test Frameworks を開く
ボタンを押下して設定を追加し、CLI Interpriterの右部の・・・を押下して
vagrant経由でリモート(Homestead)上のphpを実行する様に設定します

image.png

確認

PhpStormからPHPUnitを実行し、以下の様にテストが実行されればOKです

Testing started at 10:16 ...
vagrant://C:/Users/。。。
/home/vagrant/。。。
PHPUnit 5.7.20 by Sebastian Bergmann and contributors.

Time: 868 ms, Memory: 10.00MB

OK (1 test, 1 assertion)

Process finished with exit code 0
4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3