Setting up Xdebug with Vagrant and PHPStorm


Error message

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in _menu_load_objects() (line 569 of /homepages/46/d762693627/htdocs/dc/includes/
Setting up Xdebug with Vagrant and PHPStorm


I've never used PHPStorm before so am no expert, but here are some notes that may help those of you who use it get it working with Vagrant and Xdebug. This approach should let you use the Nginx hostnames (eg. rather than the Apache hostnames (eg., etc).

Xdebug settings

Xdebug has a config file (typically /etc/php.d/xdebug.ini) on each php environment (eg. each Apache VM).

Important settings are:

  • xdebug.remote_host - set this to the IP address of the Vagrant host (your laptop). For me this is
    • If you're having any problems, ssh into the Apache VM you're working with and make sure you can ping this IP address from the VM. If you suspect your IP address might be different, open your VirtualBox GUI and see if you can find your IP address there.
  • xdebug.remote_port - set this to port you have told your editor (PHPStorm) to listen on. This can be anything but the default is 9000.

Remember to restart Apache after making any changes to this file, in order for the changes to take effect.

Here is my d8 vm xdebug.ini file currently:

; Enable xdebug extension module
xdebug.remote_enable = 1

// Enable to connect back to Xdebug on ip the http request came from. Won't work if coming
// via Ngnix and Varnish:

// IP address to connect back to. Should be the IP address of the Vagrant host:
xdebug.remote_host =

// Enable this if you don't want to have to tell Xdebug to start via GET/POST/COOKIE:

// Enable this if you want the debugger to start when a certain key is passed with the request:



PHPStorm settings

I basically just followed this page on the PHPStorm website:

I don't know if all of these steps are necessary in PHPStorm (not sure why it needs to know about the Vagrant VM, reckon it might be possible to skip that bit) but here's how my settings look now:

PHP → Servers

PHP CLI Interpreter

PHP → Debug


In case I missed anything above, here's a video of me setting up from scratch:


The log file /var/log/xdebug.log on your Apache VMs tells you what Xdebug is trying to do. If you're having problems, these is likely to be some useful information in this log.

If the log doesn't exist, create it and make it writeable by the Apache user (or all users).

Check that you have something like this in your Xdebug config to tell it where to write the log:




blog tag: