Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

thomthom's avatar

How to debug tests running on Homestead from PhpStorm?

I got PhpStorm 2023, and a fresh copy of Vagrant and Homestead (setup yesterday) with a Laravel 10 application (migrated from 5.2).

I got PhpStorm able to run tests from Homestead. But I've not figured out how to configure everything such that I can debug the tests.

I get the following error:

Connection was not established. Debug extension is not installed

Hooking at the Laravel docs: https://laravel.com/docs/10.x/homestead

By default, Xdebug is already running and ready to accept connections.

I presume then this is a PhpStorm configuration issue?

0 likes
1 reply
LaryAI's avatar
Level 58

To debug tests running on Homestead from PhpStorm, you need to configure PhpStorm to connect to Xdebug on the Homestead virtual machine. Here's how you can do it:

  1. Make sure Xdebug is installed and enabled on your Homestead virtual machine. You can check this by SSHing into the Homestead machine and running the php -v command. Look for the Xdebug section in the output to confirm that it's installed and enabled.

  2. In PhpStorm, go to "Settings" or "Preferences" (depending on your operating system) by clicking on "File" in the menu bar and selecting "Settings" or "Preferences".

  3. In the settings window, navigate to "Languages & Frameworks" > "PHP" > "Debug".

  4. In the "Debug" settings, make sure the "Xdebug" option is selected as the debugger.

  5. Click on the "..." button next to the "Debug port" field and enter the port number that Xdebug is configured to listen on. By default, Xdebug listens on port 9000.

  6. In the "Path mappings" section, click on the "+" button to add a new path mapping. Enter the absolute path to your Laravel project directory on the Homestead virtual machine as the "Absolute path on the server". Then, enter the absolute path to the corresponding directory on your local machine as the "Absolute path on the local machine". This mapping allows PhpStorm to map the paths correctly when debugging.

  7. Click "OK" to save the settings.

  8. Now, you can run your tests in PhpStorm by right-clicking on a test file or test case and selecting "Run" or "Debug". PhpStorm will connect to Xdebug on the Homestead virtual machine and allow you to debug your tests.

If you still encounter the "Connection was not established. Debug extension is not installed" error, make sure that Xdebug is properly installed and enabled on your Homestead virtual machine. You can refer to the Laravel Homestead documentation for more information on setting up Xdebug.

Here's an example of how the path mappings might look in PhpStorm:

Absolute path on the server: /home/vagrant/code/my-laravel-project
Absolute path on the local machine: /Users/your-username/code/my-laravel-project

Make sure to replace /home/vagrant/code/my-laravel-project with the actual path to your Laravel project on the Homestead virtual machine, and /Users/your-username/code/my-laravel-project with the actual path to the corresponding directory on your local machine.

Please or to participate in this conversation.