Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

環境

  • 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
t-kuni
主にWEBとか
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした